|
-
Jun 26th, 2006, 10:10 AM
#1
Thread Starter
Hyperactive Member
[RESOLVED] iFrame problem
Hi,
I want to have a button in my iframe page which when clicked changes the parent page's webpage. If i had a hyperlink in my iframe this would be easily done by:
Code:
<a href="changePage.html" target="_parent">
The button control doesn't have a target property. I guess i will have to do this using javascript. Can anyone help me out on this code.
Thanks.
Last edited by modernthinker; Jun 27th, 2006 at 05:06 AM.
-
Jun 26th, 2006, 12:41 PM
#2
Addicted Member
Re: iFrame problem
Use the onclick event for the button to trigger a Js call like so
Code:
</head>
<script language="javascript" type="text/javascript">
<!--
function Call(){
window.open("http://www.MyWebSite.com/", "_parent");
}
//-->
</script>
<body>
<form id="form1" name="form1" method="post" action="">
<input type="button" name="Button" value="Button" id="Button1" onclick="JavaScript:Call();" />
</form>
</body>

I will wait for death with a smile and a big stick
-
Jun 27th, 2006, 05:02 AM
#3
Thread Starter
Hyperactive Member
Re: iFrame problem
This code if perfect!
I tweaked it alittle for my webpage, i have:
Code:
protected void btn_Checkout_Click(object sender, EventArgs e)
{
//Do some stuff here
Session["total"] = NewPrice;
string runJavascript = "<script type='text/javascript' language='javascript'>";
runJavascript += "javascript:window.open('myWebpage.aspx', '_parent');";
runJavascript += "</script>";
Page.RegisterStartupScript("openPageInParent", runJavascript);
}
Thanks again!
-
Jun 27th, 2006, 05:49 AM
#4
Addicted Member
Re: [RESOLVED] iFrame problem
Kewl...glad I could help 
Just so you no you probably don't need:
Code:
javascript:window.open('myWebpage.aspx', '_parent');
As the line :
Code:
window.open('myWebpage.aspx', '_parent');
Should do the same job where as the line before. Also the line before may give a JS error in some browsers, but if you find it works ok then wouldn't worry about it too much, If you also want to make it a bit more browser friendly use:
Code:
protected void btn_Checkout_Click(object sender, EventArgs e)
{
//Do some stuff here
Session["total"] = NewPrice;
string runJavascript = "<script type='text/javascript' language='javascript'>";
runJavascript += "<!--"
runJavascript += "window.open('myWebpage.aspx', '_parent');";
runJavascript += "//-->"
runJavascript += "<" + "/script>";
Page.RegisterStartupScript("openPageInParent", runJavascript);
}
Last edited by rabid lemming; Jun 27th, 2006 at 05:56 AM.

I will wait for death with a smile and a big stick
-
Jun 27th, 2006, 07:57 AM
#5
Thread Starter
Hyperactive Member
Re: [RESOLVED] iFrame problem
-
Jun 27th, 2006, 09:34 AM
#6
Addicted Member
Re: [RESOLVED] iFrame problem
np's just happy to help

I will wait for death with a smile and a big stick
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|