Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

🐛 load script inside #c container for Zucks ad #23247

Merged
merged 1 commit into from
Dec 18, 2019

Conversation

yang-wei
Copy link
Contributor

We din't load our ad inside the container #c so our ad din't show up.

@yang-wei
Copy link
Contributor Author

now it looks good

image

@yang-wei
Copy link
Contributor Author

@torch2424 Can you please have a look for me =)

Copy link
Contributor

@torch2424 torch2424 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry for the late review! Was OOO for a family event.

Everything looks good, and I tested things as well:

Screen Shot 2019-07-15 at 12 38 11 PM

Just one comment and then we can merge this 😄

loadScript(global, `https://j.zucks.net.zimg.jp/n?f=${data['frameId']}`);
const s = global.document.createElement('script');
s.src = `https://j.zucks.net.zimg.jp/n?f=${data['frameId']}`;
global.document.getElementById('c').appendChild(s);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

cc @zhouyx is this a valid use case to not use loadScript? 🤔

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm I do find loadScript can be used here. Can we switch to that helper method? Thanks.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How do I access my script dom to appendChild into document.getElementById('c') if I use the loadScript since loadScript does not return anything

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Interesting, can I know the reason why we must insert the script to the container element? Thanks.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

https://github.com/ampproject/amphtml/tree/master/ads#the-iframe-sandbox

Note that the container div (with id="c") is absolute positioned and takes the whole space of the iframe, so you will want to append your content as a child of the container (don't append to body).

without doing this our ad can't be clicked

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @yang-wei

I understand there's this container div, however the container div is within the same window, which means the script will be running with the same context no matter where it is inserted.

That said I don't think inserting <script> to document would break your use case, and I'd be very curious if it does.

However I you do insist on leaving it as it is, I'm also ok with it. Let me know Thanks.

Copy link
Contributor Author

@yang-wei yang-wei Aug 1, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

http://zucksdevelopers.vg/amp.html

Can you look at this ?

image

You can we see add an ugly css

body > div#c {
    z-index: -1;
}

If you remove this then this ad will become unclickable

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @yang-wei , unfortunately the two examples you provide, one has adType = zoe, the other has adType not defined. I couldn't test with adType=native.

That said, I found you are using the writeScript for the other ad type. It's possible that you need the script to be loaded synchronously. If so, please try using writeScript method instead. Let me know Thanks

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you mean use loadScript instead right.

I will add another example to show this

@zhouyx
Copy link
Contributor

zhouyx commented Dec 18, 2019

to @ampproject/wg-ads

@zhouyx zhouyx requested a review from lannka December 18, 2019 00:09
@lannka lannka merged commit 637397d into ampproject:master Dec 18, 2019
@yang-wei yang-wei deleted the zucks-dom-append-c branch December 18, 2019 23:54
micajuine-ho pushed a commit to micajuine-ho/amphtml that referenced this pull request Dec 27, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants