Click here to Skip to main content
15,887,596 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
In my asp.net application, I have Iframe in which i have to open new websites, for this page must redirect, how to redirect the page in Iframe???
Posted
Comments
What have you tried and where is the problem?

Hi,
Please find the code,
<html><head>
<title>Test IFrame SRC by Javascript </title>

<script>
function RedirectPage()
{
 document.getElementById("frame1").src = "http://WWW.microsoft.com";
}
</script>
</head>
<body>
<table>
<tr>
<td>
     <iframe name="frame1" src="http://www.w3schools.com" width="500px" height="500px"></iframe>
</td>
</tr>
<tr><td>
<input type="button" value="Change IFrame sRC Location" name="btnRedirect" runat="server" onclick="RedirectPage()"/>
</td></tr>
</table>

</body>
</html>
<pre>
Hope it helps
Regards,Mahe
 
Share this answer
 
Comments
Karthik_Mahalingam 18-Dec-13 1:31am    
good
try this..:)


JavaScript
function SetPage(url)
{
 
document.getElementById("myframe").setAttribute("src", url);
 
}


HTML
<iframe id="myframe"></iframe>
 
<span onclick="SetPage('MyPage1.aspx')">My Page1</span>
<span onclick="SetPage('MyPage2.aspx')">My Page2</span>
<span onclick="SetPage('MyPage3.aspx')">My Page3</span>
<span onclick="SetPage('MyPage4.aspx')">My Page4</span>
 
Share this answer
 

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