What does the browser do when javascript is the source of the iframe

When the iframe source is:

javascript:''; 

how in:

 <iframe id="SpControlFrame1" name="SpControlFrame1" src="javascript:'';" path_src="index.php?cmd=YYY" ></iframe> 

What's happening? What src = "javascript does: '';" tell the browser?

what does "path_src" do?

Thank you, Chris

+8
javascript iframe
Jan 10 '09 at 1:37
source share
2 answers

It tells the browser that it displays the result of executing an empty string literal. Therefore, it simply displays an empty string.

You can check the effect of this by entering javascript:'http://qaru.site/'; in the address bar of a regular window / tab. You will get a white page with the inscription " /qaru.site / ... ", and in fact you will not get to this URL.

This is the reason why bookmarklets often wrap code inside void() or an anonymous function that returns nothing to stop the browser from trying to display the result of the bookmarklet. For example:

 javascript:void(window.open("dom_spy.html")) 

Or:

 javascript:(function () { window.open("dom_spy.html"); })() 

If you use code that returns something (in this case, an instance of a new window), the browser will ultimately display the following:

 javascript:window.open("dom_spy.html"); 

In Firefox above will be displayed:

  [object Window] 
+14
Jan 10 '09 at 1:44
source share
— -

As far as I know, the src attribute displays iframe elements of location.href . Therefore setting src in javascript:''; a little pointless and the browser will do one of two things:

  • Ignore it because it is not a URI and does not allow any displayed resource
  • Run javascript that didn't create anything

In any case, you do very little. Is this code inherited or are you trying to do something complicated with iframe ?

+1
Jan 10 '09 at 1:45
source share



All Articles