there webpage making greasmonkey script for. page has several iframes. have found out problem, not know how solve issue.
at first script creates small div box button. pressing button script analyzes webpage contents , calls alert
on conditions.
javascript console in firefox shouts me access denied document
because script using document.getelementbyid
find top document's body, div box being appended to.
this avoidable problem script fails , gets stuck in iframes, yet still continues on main page give access document
.
the problem araises when try use alert in function. seems iframes take on script , kills permission denied access property 'alert'
.
how tell browser/script or whatever, want script run on main document , not want bothered iframes?i installed no-script addon, allowed primary domain , blocked secondary domain (that loads inside iframes) , alert messages go normal. but, can't ask users install noscript enable/disable specific domains , script should working fine. need find solution work iframes enabled.
hope didn't sound confusing.
thank help.
re:
how tell browser/script or whatever, want script run on main document , not want bothered iframes?i installed no-script addon, allowed primary domain , blocked secondary domain (that loads inside iframes) , alert messages go normal.
first, adjust include , exclude directives ignore iframes as possible. eg:
// @include http://example.com/normal/* // @include http://example.com/extra/* // @exclude http://example.com/extra/in_iframe/*
next, add these 2 lines first lines of code after metadata block:
if (window.top != window.self) //-- don't run on frames or iframes return;
that stop gm script running on iframes.
Comments
Post a Comment