Closed Thread Icon

Preserved Topic: HELP need to fined bug in 10 rows of code! (Page 1 of 1) Pages that link to <a href="https://ozoneasylum.com/backlink?for=18492" title="Pages that link to Preserved Topic: HELP need to fined bug in 10 rows of code! (Page 1 of 1)" rel="nofollow" >Preserved Topic: HELP need to fined bug in 10 rows of code! <span class="small">(Page 1 of 1)</span>\

 
Yossi Admon
Bipolar (III) Inmate

From: Israel
Insane since: Nov 2001

posted posted 11-07-2001 21:08

Hi.
I'm trying to load dynamic pages into div dinamic by causing event like klickin a button.
To do this lets assume that the code I'm trying to load knows about my div and try to write javascript code into.
If you will create html file add the following code to it and create test.txt file (in the same directory) you will notice
that if you will uncomment the script (line 6 in the html) on loading the text from the test.txt file will be loaded but
if you will press the button (and do the same thing in runtime) the div will not contain any data in the end.

Can you tell me where in the code is my bug ?????

html code:
=======

<html>
<body>
This text is in the html
<input type="button" value="Click Me" onClick="document.all.div1.innerHTML='<SCRIPT LANGUAGE=javascript src=.\/test.txt><\/SCRIPT>'">
<DIV id="div1" STYLE="position:absolute; width:30px; height:30px">
<!--<SCRIPT LANGUAGE=javascript src=./test.txt></SCRIPT>-->
</DIV>
</body>
</html>

test.txt code (simple javascript text)
========================
document.all.div1.innerHTML = "This text was loaded dynamic";




[This message has been edited by Yossi Admon (edited 11-08-2001).]

kretsminky
Maniac (V) Inmate

From: A little lower... lower... ahhhhhh, thats the spot
Insane since: Jun 2000

posted posted 11-07-2001 21:17

What the heck is

<\/SCRIPT> ? and .\/test.txt




[This message has been edited by kretsminky (edited 11-07-2001).]

Slime
Lunatic (VI) Mad Scientist

From: Massachusetts, USA
Insane since: Mar 2000

posted posted 11-08-2001 00:55

I think

<\/script>

is the problem. The "/" character does *not* need to be escaped. So you can just say </script>. However, then you're faced with another problem... you can't have a </script> inside your javascript, or the browser thinks you merely forgot to close your quotation marks before ending the script. So do this:

"...</scr" + "ipt>"

Yossi Admon
Bipolar (III) Inmate

From: Israel
Insane since: Nov 2001

posted posted 11-08-2001 07:29

I tryed this line
<input type="button" value="Click Me" onClick="document.all.div1.innerHTML='<SCRIPT LANGUAGE=javascript src=./test.txt></SCRIPT>'">

It is not working after the \ removed

Emperor
Maniac (V) Mad Scientist with Finglongers

From: Cell 53, East Wing
Insane since: Jul 2001

posted posted 11-08-2001 15:59

Yossi Admon: Welcome. I'm curious to know what you are planning. I have been fiddling around with something similar but you will run into cross browser compatibility problems but perhaps this isn't a problem.

Emps


You're my wife now Dave

jiblet
Paranoid (IV) Inmate

From: Minneapolis, MN, USA
Insane since: May 2000

posted posted 11-08-2001 16:02

Yossi, did you read what Slime said? You can't have </script> in your script. Escaping the slash doesn't help because it doesn't parse for escaped characters. Try what he recommended and see if it works.

-jiblet

Yossi Admon
Bipolar (III) Inmate

From: Israel
Insane since: Nov 2001

posted posted 11-08-2001 16:52

I tryed this line
<input type="button" value="Click Me" onClick="document.all.div1.innerHTML= '<SCR' + 'IPT LANGUAGE=javascript src=test.txt></SCR' + 'IPT>'">

It is not working after the split of the script .

My real purpose is to write jsp file in the server that will get the target div id as a parameter and in this way to replace the content of small part in the client html in runtime without refreshing the whole html.
Example lets say the html page shows table of measurements and by clicking on each cell we drill down the cell into more deta (lets asume the data came from database in the firs page was group by hours and the drill down will do the query of single hour group by minutes). if we will choose to move back we dont want to recalculate the data
so we can just hide and show divs.



Yossi Admon
Bipolar (III) Inmate

From: Israel
Insane since: Nov 2001

posted posted 11-08-2001 16:56

Another relevant Question is whether I can change the src property of an existing script in runtime and reevaluate the script?

Emperor
Maniac (V) Mad Scientist with Finglongers

From: Cell 53, East Wing
Insane since: Jul 2001

posted posted 11-08-2001 17:27

Yossi: If I understand the situation I'm wondering if it might be simpler if you could do some server side browser detection and then give people with decent browsers an IFRAME (see I'm not totally against them if used right) and then use layers for NS4.x. Actually wouldn't this work:

code:
<nolayer>

IFRAME HERE

<noframe>
You appear to have an IFRAME capable browser with IFRAME capability disabled. To view
the content enable IFRAMEs or if this isn't the case then try returning with IE or NS6.
</noframe>

</nolayer>

LAYER HERE



This should give you the power to load things into the page simply in a cross browser way (I think it should pick up most browser/platoform combinations) without too much hassle (I've played around with similar things to the script you have an it gets to be a real pain trying to get it working in various browsers.

Emps

[edit: added UBB code to make things a little clearer]


You're my wife now Dave

[This message has been edited by Emperor (edited 11-08-2001).]

Slime
Lunatic (VI) Mad Scientist

From: Massachusetts, USA
Insane since: Mar 2000

posted posted 11-08-2001 18:10

Oh, wait a minute. If I remember correctly, you're not allowed to change the innerHTML of an element to include a script tag which is supposed to load another script, and expect the new script to be run. I don't think it works like that.

Yossi Admon
Bipolar (III) Inmate

From: Israel
Insane since: Nov 2001

posted posted 11-11-2001 07:05

Thanks for all your'e tips it bwas very helpful

« BackwardsOnwards »

Show Forum Drop Down Menu