473,399 Members | 3,038 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,399 software developers and data experts.

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.iframe1 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(Object Src, EventArgs E )
{
string strjscript = "<script language='javascript'>"
+ "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:blank" name="iframe1" ID="iframe1"
width="300" height="500" frameborder="0" scrolling="auto"></iframe>
<br>
<iframe runat="server" src="about:blank" name="iframe2" ID="iframe2"
width="300" height="500" frameborder="0" scrolling="auto"></iframe>
</form>
</body>
</HTML>
Nov 18 '05 #1
2 2761
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.google.c om...
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.iframe1 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(Object Src, EventArgs E )
{
string strjscript = "<script language='javascript'>"
+ "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:blank" name="iframe1" ID="iframe1"
width="300" height="500" frameborder="0" scrolling="auto"></iframe>
<br>
<iframe runat="server" src="about:blank" 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
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...
2
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...
14
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...
1
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...
1
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...
3
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: ...
4
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;...
7
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...
1
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...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
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...
0
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,...

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.