-
Notifications
You must be signed in to change notification settings - Fork 3.9k
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
Conversation
@torch2424 Can you please have a look for me =) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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); |
There was a problem hiding this comment.
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
? 🤔
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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 ?
You can we see add an ugly css
body > div#c {
z-index: -1;
}
If you remove this then this ad will become unclickable
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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
to @ampproject/wg-ads |
We din't load our ad inside the container #c so our ad din't show up.