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

Insertion of gpt.js fails when the document doesn't have existing scripts #119

Open
venkatkarun opened this issue Feb 19, 2016 · 3 comments

Comments

@venkatkarun
Copy link

Not having scripts in the head or body might be weird but is quite prevalent as can be gauged by websites like http://www.csszengarden.com/215/. It will be nice to make jquery.dfp defensive as opposed to failing badly in such a scenario.

TypeError: Cannot read property 'parentNode' of undefined
at dfpLoader (chrome extension://bekccbechiigcepdoebmbganlaehelkj/bower_components/jquery.dfp/jquery.dfp.js:545:17)


 var useSSL = 'https:' === document.location.protocol;
 gads.src = (useSSL ? 'https:' : 'http:') + '//www.googletagservices.com/tag/js/gpt.js';
 var node = document.getElementsByTagName('script')[0];
 node.parentNode.insertBefore(gads, node);
@soreng
Copy link
Contributor

soreng commented Feb 19, 2016

How do you insert the script without having any script-Blocks on the page?

Also, the lib requires jQuery. How are you using it?

On 19. feb. 2016, at 18.16, Venkat Karun [email protected] wrote:

Not having scripts in the head or body might be weird but is quite prevalent as can be gauged by websites like http://www.csszengarden.com/215/. It will be nice to make jquery.dfp defensive as opposed to failing badly in such a scenario.

TypeError: Cannot read property 'parentNode' of undefined
at dfpLoader (chrome extension://bekccbechiigcepdoebmbganlaehelkj/bower_components/jquery.dfp/jquery.dfp.js:545:17)

var useSSL = 'https:' === document.location.protocol;
gads.src = (useSSL ? 'https:' : 'http:') + '//www.googletagservices.com/tag/js/gpt.js';
var node = document.getElementsByTagName('script')[0];
node.parentNode.insertBefore(gads, node);

Reply to this email directly or view it on GitHub.

@venkatkarun
Copy link
Author

The parent script that requires $.dfp is inserted as a chrome extension content script. jquery itself is required from the parent script.

@coop182
Copy link
Owner

coop182 commented Feb 22, 2016

Hey @venkatkarun send me a pull request with something that works for your page and I will make sure it works elsewhere and merge it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants