Click here to Skip to main content
14,875,904 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
I am trying to develop a very small system using asp.net iframes.i have developed a page saying search.aspx and have used iframes in this to show Google, yahoo, Cuil, Bing etc on button click like this code

HTML
<pre lang="xml"><html>
<head>
<meta http-equiv="Content-Language" content="en-gb">
<meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
<link href="searchstyle.css" rel="stylesheet" type="text/css" />
<title>Search Domain</title>
<meta name="description" content="">
</head>
<body>
<div align="center" style="font-size: x-small; font-family: arial, helvetica, sans-serif">
<form name="jumpy">
<select name="example" size="1" onChange="gone()">
<option value="http://www.yahoo.com" selected>Yahoo.com</option>
<option value="http://www.google.com">Google.com</option>
<option value="http://www.news.com">News.com</option>
<option value="http://www.altavista.com">AltaVista.com</option>
<option value="http://www.gmail.com">Gmail.com</option>
<option value="http://www.nasa.gov">Nasa.gov</option>
<option value="http://www.rediffmail.com">rediffmail.com</option>
<option value="http://www.customise.com">Customise</option>
</select>
<input type="button" name="test" value="Go!" onClick="gone()"/>
<input type="Text" name="customise" disabled="disabled" title="Enter Ur Search Url"/>
<input type="button" name="test1" value="Get!" onClick="go()" disabled="disabled"/>
</form>
<script language="javascript" type="text/javascript">
<!--
//Specify display mode (0 or 1)
//0 causes document to be displayed in an inline frame, while 1 in a new browser window
var displaymode=0
//if displaymode=0, configure inline frame attributes (ie: dimensions, intial document shown
var iframecode='<iframe id="external" style="width:100%;height:100%" src="http://www.yahoo.com"></iframe>'
/////NO NEED TO EDIT BELOW HERE////////////
if (displaymode==0)
document.write(iframecode)
function gone()
{
var selectedurl=document.jumpy.example.options[document.jumpy.example.selectedIndex].value
if( selectedurl == 'http://www.customise.com')
{
document.jumpy.example.disabled = true
document.jumpy.test.disabled = true
document.jumpy.customise.disabled = false
document.jumpy.test1.disabled = false
}
else
{
if (document.getElementById&&displaymode==0)
document.getElementById("external").src=selectedurl
else if (document.all&&displaymode==0)
document.all.external.src=selectedurl
else{
if (!window.win2||win2.closed)
win2=window.open(selectedurl)
//else if win2 already exists
else{
win2.location=selectedurl
win2.focus()
}
}
}
}

function go()
{
var selectedurl=document.jumpy.customise.value
if (document.getElementById&&displaymode==0)
document.getElementById("external").src=selectedurl
else if (document.all&&displaymode==0)
document.all.external.src=selectedurl
else{
if (!window.win2||win2.closed)
win2=window.open(selectedurl)
//else if win2 already exists
else{
win2.location=selectedurl
win2.focus()
}
}
}
//-->
</script>
</div>
</body>
</html>

HTML
<pre lang="HTML">


but the problem is that i want to insert these scripts

XML
<script type="text/javascript">
document.oncontextmenu=new Function("return false");
</script>


and

XML
<script type="text/javascript" src="www.xyz-abc.co.in/js/..../me.js">
</script>



after iframe load the contents, this javascript should merge into the loading contents and should run in the page being loaded. could any one can suggest me. i have checked it using jquery but no results.

in other words i want to run a script file inside the iframe each and evry time new contents are loaded to iframe.
Posted
Comments
Denno.Secqtinstien 29-Nov-11 3:53am
   
can any one help in this regards

1 solution

If you own the page which you are framing, then you simply put the script include on that page.
You can't and shouldn't be able to inject your javascript into a page not owned by you. Think about the security implications. That would be silly.
   
Comments
Denno.Secqtinstien 29-Dec-11 0:55am
   
your answer is appreciate marcus, its the requirement of my work elese i have to drop this project.
Denno.Secqtinstien 20-Jan-12 1:47am
   
thanks, dropped it.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)




CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900