Results 1 to 6 of 6

Thread: [RESOLVED] iFrame problem

  1. #1

    Thread Starter
    Hyperactive Member
    Join Date
    Oct 2002
    Location
    The Twilight Zone
    Posts
    295

    [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.

  2. #2
    Addicted Member rabid lemming's Avatar
    Join Date
    Feb 2005
    Posts
    210

    Resolved 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

  3. #3

    Thread Starter
    Hyperactive Member
    Join Date
    Oct 2002
    Location
    The Twilight Zone
    Posts
    295

    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!

  4. #4
    Addicted Member rabid lemming's Avatar
    Join Date
    Feb 2005
    Posts
    210

    Smile 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

  5. #5

    Thread Starter
    Hyperactive Member
    Join Date
    Oct 2002
    Location
    The Twilight Zone
    Posts
    295

    Re: [RESOLVED] iFrame problem

    Cool, thanks for that.

  6. #6
    Addicted Member rabid lemming's Avatar
    Join Date
    Feb 2005
    Posts
    210

    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
  •  



Click Here to Expand Forum to Full Width