473,700 Members | 2,500 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

HELP: Changing ilayer src from a href link...


I'm trying to change the src of an ilayer in the parent document from a link inside the
ilayer. I'm not able to get it to work. All that happens is Netscape 4 crashes. This is
for Netscape 4 only.
For example, here is the main page:

<html>
<head>
<script type="text/javascript">
function updateILayer(ob j) {
parent.document .layers["layer1"].src = obj.href;
}
</script>
</head>

<body>
<ilayer name="layer1" id="layer1" src="home.htm">
</ilayer>
</body>
</html>

And here's the home.htm src:

<html>
<head>
</head>

<body>
Click this link to go to test page:
<a onClick="parent .updateILayer(t his);" href="test.htm" >test</a>
</body>
</html>

And here's the test.htm src:

<html>
<head>
</head>

<body>
Click this link to go to home page:
<a onClick="parent .updateILayer(t his);" href="home.htm" >home</a>
</body>
</html>

Jul 20 '05 #1
14 2505
Well, to keep it from crashing when you click on the link, I've change the function as such:

function updateILayer(ob j) {
eval("parent.do cument.layer1.s rc=" + obj.href);
}

But it still doesn't work. It just goes to that link and doesn't change the ilayer src. I
can tell because I've add <hr> around the <ilayer> so if the ilayer src is changed then
the <hr> would still be there.

Brandon Hoppe wrote:

I'm trying to change the src of an ilayer in the parent document from a
link inside the ilayer. I'm not able to get it to work. All that happens
is Netscape 4 crashes. This is for Netscape 4 only.
For example, here is the main page:

<html>
<head>
<script type="text/javascript">
function updateILayer(ob j) {
parent.document .layers["layer1"].src = obj.href;
}
</script>
</head>

<body>
<ilayer name="layer1" id="layer1" src="home.htm">
</ilayer>
</body>
</html>

And here's the home.htm src:

<html>
<head>
</head>

<body>
Click this link to go to test page:
<a onClick="parent .updateILayer(t his);" href="test.htm" >test</a>
</body>
</html>

And here's the test.htm src:

<html>
<head>
</head>

<body>
Click this link to go to home page:
<a onClick="parent .updateILayer(t his);" href="home.htm" >home</a>
</body>
</html>


Jul 20 '05 #2
Brandon Hoppe <bh****@ti.co m> writes:
Well, to keep it from crashing when you click on the link, I've change the function as such:

function updateILayer(ob j) {
eval("parent.do cument.layer1.s rc=" + obj.href);
}
Don't use "eval", ever. There are better ways to do what you want
(where better is several of: shorter, faster, uses less momory, and is
less error prone). The exceptions are so few and rare, that you are
unlikely to hit one by accident.

If obj.href contains "http://www.example.com ", your construction above
will try to eval the following string:
"parent.documen t.layer1.src=ht tp://www.example.com "
Notice that there are no quotes around the part after the "=", so
it is just one big syntax error.

Try:

parent.document .getElementById ("layer1").src= obj.href

(layers are generally not represented by global variables, you need
to find them the hard way).

You could probably also do:
parent.layers["layer1"].location.href = obj.href;
But it still doesn't work. It just goes to that link and doesn't
change the ilayer src.
Guess: you need to return false.
I can tell because I've add <hr> around the
<ilayer> so if the ilayer src is changed then the <hr> would still be
there.

<a onClick="parent .updateILayer(t his);" href="test.htm" >test</a>


Yep, remember to return false:
<a href="test.htm"
onclick="parent .updateILayer(t his);return false">test</a>
Returning false prevents the normal operation of the link (following
it).

/L
--
Lasse Reichstein Nielsen - lr*@hotpop.com
DHTML Death Colors: <URL:http://www.infimum.dk/HTML/rasterTriangleD OM.html>
'Faith without judgement merely degrades the spirit divine.'
Jul 20 '05 #3
Lasse Reichstein Nielsen wrote:
Don't use "eval", ever. There are better ways to do what you want
(where better is several of: shorter, faster, uses less momory, and is
less error prone). The exceptions are so few and rare, that you are
unlikely to hit one by accident.

If obj.href contains "http://www.example.com ", your construction above
will try to eval the following string:
"parent.documen t.layer1.src=ht tp://www.example.com "
Notice that there are no quotes around the part after the "=", so
it is just one big syntax error.
Yeah, I've never used eval but I was just trying anything at this point.
Try:

parent.document .getElementById ("layer1").src= obj.href

(layers are generally not represented by global variables, you need
to find them the hard way).
Nope.
You could probably also do:
parent.layers["layer1"].location.href = obj.href;
Nope.
Yep, remember to return false:
<a href="test.htm"
onclick="parent .updateILayer(t his);return false">test</a>
Returning false prevents the normal operation of the link (following
it).


Oh yeah, forgot to return false. Ok, I've added return false but it still just goes to
that link. I've tried these lines in the function call but neither worked:

parent.document .layer1.src=obj .href;
parent.document .getElementById ("layer1").src= obj.href;
parent.document .layers["layer1"].src=obj.href;
parent.layers["layer1"].location.href= obj.href;

I've read you can change the ilayer src link but I haven't seen it done yet lol :)

Jul 20 '05 #4
Hell, I've even simplified so that the link is on the main page and I'm trying to change
the ilayer src:

<html>
<head>
<!--
parent.document .layer1.src=obj .href;
parent.document .getElementById ("layer1").src= obj.href;
parent.document .layers("layer1 ").src=obj.href ;
parent.document .layers["layer1"].src=obj.href;
parent.layers["layer1"].location.href= obj.href;
-->
<script type="text/javascript">
function updateILayer(ob j) {
document.layer1 .src=obj.href;
}
</script>
</head>

<body>
<a onClick="update ILayer(this);re turn false;" href="test.htm" >TEST</a>
<a onClick="update ILayer(this);re turn false;" href="home.htm" >HOME</a>
<hr>
<ilayer name="layer1" id="layer1" src="home.htm">
</ilayer>
<hr>
</body>
</html>

This doesn't work either. The ilayer area between the <hr> just goes blank when I click
the link.
Brandon Hoppe wrote:
Lasse Reichstein Nielsen wrote:
Don't use "eval", ever. There are better ways to do what you want
(where better is several of: shorter, faster, uses less momory, and is
less error prone). The exceptions are so few and rare, that you are
unlikely to hit one by accident.

If obj.href contains "http://www.example.com ", your construction above
will try to eval the following string:
"parent.documen t.layer1.src=ht tp://www.example.com "
Notice that there are no quotes around the part after the "=", so
it is just one big syntax error.

Yeah, I've never used eval but I was just trying anything at this point.
Try:

parent.document .getElementById ("layer1").src= obj.href

(layers are generally not represented by global variables, you need
to find them the hard way).

Nope.
You could probably also do:
parent.layers["layer1"].location.href = obj.href;

Nope.
Yep, remember to return false:
<a href="test.htm" onclick="parent .updateILayer(t his);return
false">test</a>
Returning false prevents the normal operation of the link (following
it).

Oh yeah, forgot to return false. Ok, I've added return false but it
still just goes to that link. I've tried these lines in the function
call but neither worked:

parent.document .layer1.src=obj .href;
parent.document .getElementById ("layer1").src= obj.href;
parent.document .layers["layer1"].src=obj.href;
parent.layers["layer1"].location.href= obj.href;

I've read you can change the ilayer src link but I haven't seen it done
yet lol :)


Jul 20 '05 #5
"Brandon Hoppe" <bh****@ti.co m> wrote:
Hell, I've even simplified so that the link is on the main page
and I'm trying to change the ilayer src:

<snip>

It is a very long time since I have used an ILAYER, and I am not at home
so I cannot check the book that I have that lists its characteristics ,
but I seem to remember that you just cannot change their - src -
property.

As I recall the approach that works is to nest a LAYER inside the ILAYER
and change its - src - instead. That required that the property accessor
for the - src - access the outer ILAYER in the document and then the
LAYER within the document.layers collection of the ILAYER.

Developing exclusively for Netscape 4 is an odd thing to be doing in
2004.

Richard.

Jul 20 '05 #6
Richard Cornford wrote:
As I recall the approach that works is to nest a LAYER inside the ILAYER
and change its - src - instead. That required that the property accessor
for the - src - access the outer ILAYER in the document and then the
LAYER within the document.layers collection of the ILAYER.


Now that works great if I change the layer src from a link in the parent document.

But if I use a link inside the src document of the layer, then Netscape crashes. Any ideas
why?

Jul 20 '05 #7
Brandon Hoppe <c1**********@h ome.itg.ti.com> wrote:
Richard Cornford wrote:
As I recall the approach that works is to nest a LAYER inside the
ILAYER and change its - src - instead. That required that the
property accessor for the - src - access the outer ILAYER in the
document and then the LAYER within the document.layers collection
of the ILAYER.


Now that works great if I change the layer src from a link in the
parent document.

But if I use a link inside the src document of the layer, then
Netscape crashes. Any ideas why?


For future reference, If you ask questions on this group and don't
provide access to the code under discussion (and preferably in an easily
testable form) you are likely to find the process of getting help at
least slow and often fruitless.

Without code I can only guess at what you are doing so if my best guess
does not correspond with what you are doing (that is, you are doing
something other than what I guess you are doing and that is causing the
problem) then you will have wasted my time answering at all. Which
wouldn't encourage me to help next time (or anyone else who isn't
willing to show their code).

However, there certainly are problems with Netscape 4 while trying to
swap content from within the content that is to be replaced (as I recall
most apparent on Unix/Linux versions). I don't recall if there was a
good solution (as I said, it has been a long time) but I would expect
that decoupling the swapping of the content using a (global) setTimeout
call might work.

You would create a global function that actually swapped the - src -
that was called with the target URL as a string parameter (and possibly
any variable information required to resolve the reference to the ILAYR
and LAYER elements). And then, from within the layer, call
window.setTimeo ut with an argument that would call that function and
provide the required URL, etc, as string literal parameters, with a
smallish delay. That way the execution of the - src - swapping function
should behave the same as swapping the - src - from outside of the
LAYER.

Richard.
Jul 20 '05 #8
Richard Cornford wrote:
For future reference, If you ask questions on this group and don't
provide access to the code under discussion (and preferably in an easily
testable form) you are likely to find the process of getting help at
least slow and often fruitless.

Without code I can only guess at what you are doing so if my best guess
does not correspond with what you are doing (that is, you are doing
something other than what I guess you are doing and that is causing the
problem) then you will have wasted my time answering at all. Which
wouldn't encourage me to help next time (or anyone else who isn't
willing to show their code).
Of course. Sorry about that. I usually always do that. I completely agree with you. The
code that I have now is pasted at the bottom of this message.
However, there certainly are problems with Netscape 4 while trying to
swap content from within the content that is to be replaced (as I recall
most apparent on Unix/Linux versions).
Ahh. You've hit up on a good point there. I've been trying this with NN 4.7 on Solaris.
When I tried it using NN 4.7 on Windows, it worked perfectly. But I'd still like to get
this working on UNIX systems as well.
I don't recall if there was a
good solution (as I said, it has been a long time) but I would expect
that decoupling the swapping of the content using a (global) setTimeout
call might work.

You would create a global function that actually swapped the - src -
that was called with the target URL as a string parameter (and possibly
any variable information required to resolve the reference to the ILAYR
and LAYER elements). And then, from within the layer, call
window.setTimeo ut with an argument that would call that function and
provide the required URL, etc, as string literal parameters, with a
smallish delay. That way the execution of the - src - swapping function
should behave the same as swapping the - src - from outside of the
LAYER.

Richard.


Ok, I've tried it using window.setTimeo ut(). But in the layer is this error when I click
any link, either on the main page or in home/test page:

Not Found

The requested object does not exist on this server. The link you
followed is either outdated, inaccurate, or the server has been
instructed not to let you have it. Please inform the site
administrator of the referring page.
Here's the code:

<!-- MAIN.HTM -->
<html>
<head>
<script type="text/javascript">
function changeLayer(obj ) {
document.ilayer Name.document.l ayerName.src = obj.href;
}
</script>
</head>

<body>
COOL<br>
<a href="./test.htm" onclick="window .setTimeout('ch angeLayer(this) ', 100); return
false;">TEST</a><br>
<a href="./home.htm" onclick="window .setTimeout('ch angeLayer(this) ', 100); return
false;">HOME</a><br>
<hr>
<ilayer name="ilayerNam e" id="ilayerName " width=500 height=500>
<layer name="layerName " id="layerName" src="home.htm" width=500 height=500></layer>
</ilayer>
<hr>
</body>
</html>

<!-- HOME.HTM -->
<html>
<head>
</head>
<body>
<a href="test.htm" onclick="window .setTimeout('pa rent.changeLaye r(this)', 100); return
false;">TEST</a><br>
HOME PAGE
</body>
</html>

<!-- TEST.HTM -->
<html>
<head></head>
<body>
<a href="home.htm" onclick="window .setTimeout('pa rent.changeLaye r(this)', 100); return
false;">HOME</a><br>
TEST PAGE
</body>

Jul 20 '05 #9
Brandon Hoppe <c1**********@h ome.itg.ti.com> wrote:
Richard Cornford wrote: <snip>
You would create a global function that actually swapped the - src -
that was called with the target URL as a string parameter ...

<snip>
function changeLayer(obj ) {
document.ilayer Name.document.l ayerName.src = obj.href;
}
I said that you should use a string parameter because you cannot
reliably use an object reference in the string argument for a steTimeout
call unless that reference is via, or to, a global property. String
argument setTimout code is always executed in a global context
(specifically, the global context to which the setTimout function that
is called belongs).

function changeLayer(url ) { //pass the url as a string
document.ilayer Name.document.l ayerName.src = url;
}

<snip> <a href="./test.htm" onclick="window .setTimeout('ch angeLayer(this) ',
100); return false;">TEST</a><br>
you should not need the setTimout call from code outside the layer. You
may as well call the - changeLayer - function directly. Changing the
object reference argument to a string:-

onclick="change Layer(this.href );return false;"

<snip> <!-- HOME.HTM --> <snip> <a href="test.htm"
onclick="window .setTimeout('pa rent.changeLaye r(this)', 100);
return false;">TEST</a><br>

<snip>

When the string argument to this setTimout call is executed in the
global context the - this - keyword will refer to the window (global)
object. It does not have a - href - property, so it is the value -
undefined - that will be assigned to the - src - property of the LAYER.
Assuming that the internal setter for - src - type-converts its
parameter into a string, the URL assigned will be "undefined" and that
resource will not be found. Also, there is no point in prefixing the
call to - changeLayer - with "parent." as the setTimout code will
execute in a context where - changeLayer - is directly accessible. Try:-

onclick="window .setTimeout('ch angeLayer(\''+t his.href+'\')', 100);
return false;"

- (correcting for line wrapping) instead.

Richard.
Jul 20 '05 #10

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

Similar topics

6
6324
by: mike | last post by:
Hello, After trying to validate this page for a couple of days now I was wondering if someone might be able to help me out. Below is a list of snippets where I am having the errors. 1. Line 334, column 13: there is no attribute "SRC" <bgsound src="C:\My Documents\zingwent.mids"> You have used the attribute named above in your document, but the document type you are using does not support that attribute for this element. This error is...
2
3233
by: mike | last post by:
Hello, I created a website with a ilayer tag which is only good for netscape. And the problem that I am having is that I want to validate my website. Of course this will not work because I have a ilayer tag which is not exceptiable to the w3. From what I have heard is that it is possible to create a ilayer as a css. I was wondering does anyone have a example on how to do this. Here is the code I have: <table width=468 border=0...
7
1866
by: mike | last post by:
Hello, I am kind of new to this javascript stuff and I am constantly having problems trying to get my webpage validated. I have the following <script>printdate();</script> and when I validate it at validator.w3.org I get a error the attribute given above is required for an element that you've used, but you have omitted it. For instance, in most HTML and XHTML document types the "type" attribute is required on the "script" element and the...
3
1783
by: P Wolpert | last post by:
This is my first post. I hope I don't sound stupid. I have a script conflict when I put two scripts on one page. Both scripts will work if I use one at a time but the menu button script will not work when I add the scrolling text script. One script, the menu button script, has an "Onload" command and the other one does not. From what I know, and that's not much, I need to put both scripts in the "Onload" command. I just don't know how to...
9
4183
by: mike | last post by:
Hello, Can some one help me with the problem that I am having to validate this. Here is the code I have: <ilayer name="test34i"><div id="test34"><img src="wavestest.gif" alt="test"></div></ilayer> Here is the error it is giving me: You have used the attribute named above in your document, but the document type you are using does not support that attribute for this element. This error is often caused by incorrect use of the "Strict"...
1
1543
by: stalinmaddy | last post by:
I have problem with layers in my code. The problem is that it works well with ordinary html files but when include with any other files which have flash script or more javascript it doesn't work.....it doesn't able to drag on these files my code is here.. <div id='theLayer' style='position:relative;width:250px;left:100;top:100;visibility:hidden' > <table border='0' width='250' bgcolor='#424242' cellspacing='0' cellpadding='5'> <tr> <td...
2
2037
by: gunnuk | last post by:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /> <title>WELCOME TO HEMA CREATIVE HOUSE</title> <style type="text/css"> <!-- @import url("css/IDESIGN 1.css"); @import url("css/IDESIGN.2.css"); body {
10
1814
by: smartphreak | last post by:
having some difficulty with removing some img's out of an ilayer... i have a frame with a scroll text within an ilayer that works off a rollover.. sample: <html> <head> <title></title> <script language="JavaScript1.2">
0
8645
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
9075
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8973
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
7810
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
6561
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
5903
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4404
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...
2
2392
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2028
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.