spiriad Posted June 9, 2009 Share Posted June 9, 2009 Hello,I would like to know how can I load a page in a iframe but with some added things to it (like scripts, header, etc). Suppose I have this example : <html><head><script type="text/javascript">function rightButton(event){ if (event.button==2) alert("You clicked the right mouse button!")}</script></head><body onmousedown="rightButton(event)"><p>Right button alert. </p></body></html> which alerts you when you click the right mouse button. And now, suppose I have the following iframe : <iframe src="http://google.com" name="show" height = "400" width = "400"></iframe> My question is how to "inject" into the iframe source the script I've talked about, and the declaration : <body onmousedown="rightButton(event)"> so that the script can be used (so when I click the right button on the google page in the iframe the alert should apear).Considering that the pages that will be displayed in the iframe (in the example, google.com) aren't editable, how can I do this thing ?Hope someone can help me !P.S. : The script I want to insert is just an example, but the solution should work for any scriptRegards,Adi Link to comment Share on other sites More sharing options...
chibineku Posted June 9, 2009 Share Posted June 9, 2009 Seems an odd thing to want to do...what is your overall goal? Link to comment Share on other sites More sharing options...
spiriad Posted June 9, 2009 Author Share Posted June 9, 2009 My goal is to implement an advance script instead of that "right click alert" one, so that when you right click a link, instead of the firefox context menu, it will appear a custom menu done by myself. The menu will contain something like "add to bookmark" and others. For sure, it will have (a) functionality , but before I do that I must succeed with this simple example.So, is there anyone who can help ? Link to comment Share on other sites More sharing options...
spiriad Posted June 9, 2009 Author Share Posted June 9, 2009 What I really want, as final goal, is to have in that iframe, a specific context menu when I click the right mouse button. Instead of "Back, Reload, Forward, Save as, etc" options which you get normally from the browser, I would like to have my own list. Ok, I know how to do this , but only on my pages (which are editable) .The thing is that I would like to implement this globally (so that it will work no matter what page is loaded in the iframe) Link to comment Share on other sites More sharing options...
Ingolme Posted June 9, 2009 Share Posted June 9, 2009 Javascript is not able to access anything in an iframe if the iframe is in a different domain than your page. Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.