473,788 Members | 2,652 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

button won't redirect child Iframes with javascript

dh
How can a button that resides on the Main page tell the child Iframes
to redirect without the page posting back? I keep getting a javascript
error: "frames.ifr ame1 is null or not an object." I'm assuming this is
because when i press the button it reloads the page and the frames
can't be referenced.

here's a simple example:

<HTML>
<script language="C#" runat="server">
void Submit_Click(Ob ject Src, EventArgs E )
{
string strjscript = "<script language='javas cript'>"
+ "frames[\'iframe1\'].location='http ://www.google.com' ;"
+ "frames[\'iframe2\'].location='http ://www.yahoo.com'; "
+ "</script" + ">";
Response.Write( strjscript);
}
</script>
<body>
<form runat="server">
<input type="submit" Value="Update Iframes"
OnServerClick=" Submit_Click" runat="server" ID="Submit"
NAME="Submit"/>

<iframe runat="server" src="about:blan k" name="iframe1" ID="iframe1"
width="300" height="500" frameborder="0" scrolling="auto "></iframe>
<br>
<iframe runat="server" src="about:blan k" name="iframe2" ID="iframe2"
width="300" height="500" frameborder="0" scrolling="auto "></iframe>
</form>
</body>
</HTML>
Nov 18 '05 #1
2 2788
Put your script code to the end of the page. Then the IFrames will exist on
execution.

HTH,
Axel Dahmen

--------------
"dh" <cm******@yahoo .com> schrieb im Newsbeitrag
news:72******** *************** ***@posting.goo gle.com...
How can a button that resides on the Main page tell the child Iframes
to redirect without the page posting back? I keep getting a javascript
error: "frames.ifr ame1 is null or not an object." I'm assuming this is
because when i press the button it reloads the page and the frames
can't be referenced.

here's a simple example:

<HTML>
<script language="C#" runat="server">
void Submit_Click(Ob ject Src, EventArgs E )
{
string strjscript = "<script language='javas cript'>"
+ "frames[\'iframe1\'].location='http ://www.google.com' ;"
+ "frames[\'iframe2\'].location='http ://www.yahoo.com'; "
+ "</script" + ">";
Response.Write( strjscript);
}
</script>
<body>
<form runat="server">
<input type="submit" Value="Update Iframes"
OnServerClick=" Submit_Click" runat="server" ID="Submit"
NAME="Submit"/>

<iframe runat="server" src="about:blan k" name="iframe1" ID="iframe1"
width="300" height="500" frameborder="0" scrolling="auto "></iframe>
<br>
<iframe runat="server" src="about:blan k" name="iframe2" ID="iframe2"
width="300" height="500" frameborder="0" scrolling="auto "></iframe>
</form>
</body>
</HTML>

Nov 18 '05 #2
d h
It still didn't work. Plus, I'll be executing that script in my
codebehind file anyway. So, putting it at the end of the page can't be
an option. Thanks.

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Nov 18 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

6
14658
by: Jeff | last post by:
I've searched the web for hours trying to figure out this problem and can't seem to find any pertinent answers. I have a website where the user starts on a login page, puts in their credentials and hits a submit button, which then takes the user to a 2nd PHP page which simply runs PHP code that checks the user's credentials from my database, and if authenticated creates a session, assigns a few session variables (including a session...
2
4557
by: Randell D. | last post by:
Folks, I have got this working before, in part with some help from this ng but I never really understood how I got it working... and last time, I was using it via a popup window as opposed to an IFRAME. I've got several months of javascript under my belt and can resolve most things without errors in my Mozilla Javascript Console, but this one just does not do it for me. This is the picture:
14
5486
by: tshad | last post by:
I posted this on the asp.net group, also. I wasn't sure whether this was an asp.net problem or a javascript problem. I have a page that was originally created from a program I found on the net that works well as an html page. It brings up a modal popup window that I have been trying to work out for days now and this was the closest I have been able to come. I added a little asp.net code and an asp.net button and cannot get it to
1
1798
by: ticars | last post by:
I have a web page which all it does is redirect a user to a different page (the page to redirect to is based on a database lookup). I want to make it so that when a user tries to use the back button, they don't rehit the redirect page. Is this possible? I know Response.Redirect won't do it, I tried Server.Transfer but received errors. Any ideas?
1
2682
by: user | last post by:
I have a parent aspx page with a few iframes. Each of the iframes show an aspx page with a datagrid whose rows all show editable entry fields at all times. The user can enter values into the parent page's form and into the iframes' datagrids and then press a save button on the parent page. My question is: from the parent's Save_Click event in the code-behind, how do I call the SaveGrid procedures I've written on each of the iframe pages...
3
2634
by: William Sullivan | last post by:
Have a frameset HTML page (parent) with child .aspx pages. When each of the child pages loads, it checks to see if the user is authenticated, and if not, redirects to the login page: if(!this.Context.User.Identity.IsAuthenticated) { Response.Redirect("Login.aspx",true); } The problem is that if I go to the parent page directly, I get four versions
4
6538
by: Ryan | last post by:
Hello, I have a standard HTML button on an aspx web form that I have set to runat server. The button is named reset1 and its tag is as follows: <INPUT id="btnReset1" style="WIDTH: 60px; HEIGHT: 24px" type="reset" value="Reset" name="btnReset1" runat="server"> Using Interdev I then double click the button in design view and in the code behind page (aspx.vb) have the following:
7
2488
by: Sridhar | last post by:
Hi, I have a question regarding the Page_Load method and Back Button of Internet explorer. I have created a webform. In that webform I have several Text Boxes. Also I have two buttons. When I click on button1, it populates the text boxes with person1 details. When I click on button2, it populates the text box with person2 details and redirects to webform2. In webform2 if I click on Back Button of Internet Explorer it should display...
1
1982
by: thomas.humberset | last post by:
Hello! Could someone please help me on the following case. I have a page that opens a popup/child-window (window.open(...)). This childwindow redirects the mainwindow and closes itself if everything is ok. BUT, the problem is when a user closes the childwindow using the x before redirect has activatet from the childwindow. Then the mainwindow is stuck on the waiting page. However, I get the mainwindow to check if child is closed using
0
9656
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
10366
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
9967
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
8993
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7517
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5399
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5536
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
3674
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2894
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.