Reputation: 2744
I have written the following Javascript code :
var outerFrame = document.getElementById("myframe");
var outerDoc = outerFrame.contentDocument || outerFrame.contentWindow.document;
var innerFrame = outerDoc.getElementsByName("frame").item(0);
var innerDoc = innerFrame.contentDocument || innerFrame.contentWindow.document;
var arr=[10,11,12,13,14,15,16,17,18,19,110,111,112,113,114,115,116,117,118,119];
for(i=0;i<20;i++){
var randomVal = Math.floor((Math.random()*5));
if (innerDoc.getElementsByName("point"+arr[i])[randomVal]) {innerDoc.getElementsByName("point"+arr[i])[randomVal].checked = true; }
}
I want people to be able to run it when on a particular website by copy-pasting it to the address bar. A little Google search tells me I need to append 'javascript:' before it. However, it does not work; nothing happens when I try to execute the code from the address bar. The code runs fine when I execute it from the console.
An error that comes up when trying to execute it from the address bar is :
uncaught exception: ReferenceError: document is not defined
Any help ?
Upvotes: 2
Views: 1375
Reputation: 1739
I'm pretty sure what you want is this question: Firefox 6 javascript in addressbar ; tl;dr Firefox (among others) won't allow you to run javascript snippets in the address bar anymore.
Upvotes: 4