質問

i saw in a few places that you can execute code using the address bar, so to test it out i typed in javascript:alert("hello"); and i pressed [ENTER] yet nothing happens.

i have even tried code someone else wrote from here.

javascript:(function%20nomify(){var
%20shapes={"w_rect":["cookiemonstercrumbypicturesopen-o.gif","tumblr_mohxt1V6a91svhqpoo1_500.gif","tumblr_md0q05wMJb1rxis0k.gif","tumblr_ml0nmjWpX41snjjivo1_500.gif","cookie4.gif"],
"t_rect":["CookieMonster-Sitting.jpg","487961_10150955894571587_1215263686_n.jpg","534767_10151516100086587_1790492047_n.jpg","patientmonster.png"],
"square":["cookie_monster.jpg","935823_10151502554911587_1547641144_n.jpg","902502_10151355606796587_45192127_o.jpg","cookie-monster.jpg"]},
img_path="http://downloads.cdn.sesame.org/sw/OmNomNomify/";function%20chooseImg(shape){return%20img_path+shapes[shape]
[Math.floor(Math.random()*shapes[shape].length)]}function%20getShape(h,w)
{return%20h===w?"square":h>w?"t_rect":"w_rect"}var%20imgs=document.getElementsByTagName("img"),
img,h,w,shape;for(var%20i=0,len=imgs.length;i<len;i++){img=imgs[i],h=img.height,w=img.width,s=getShape(h,w);img.setAttribute("height",h);
img.setAttribute("width",w);img.src=chooseImg(s)};return%20void%200;})()

i am running firefox 24.0.

is this a security thing precaution? am i doing it wrong? can you really execute code usinf the address-bar?

役に立ちましたか?

解決

For security reasons, Firefox 6 severely limited what can be done with JavaScript via the address bar.

https://bugzilla.mozilla.org/show_bug.cgi?id=656433

If you open the error console, you'll see a message indicating that alert is an undefined function.

Chrome will allow JavaScript in the address bar, but it'll strip the javascript: off if you copy+paste into it (as a different approach to the same security problem).

ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top