JavaScript and client side scripting.
Moderator: General Moderators
raghavan20
DevNet Resident
Posts: 1451 Joined: Sat Jun 11, 2005 6:57 am
Location: London, UK
Contact:
Post
by raghavan20 » Fri Aug 12, 2005 9:24 am
I have got a html file which works fine when run on my local machine.
But when I upload the file to the hosting server and run it from there, it does not work the way it should.
Code: Select all
<!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>Chat Application - Retrieve messages</title>
<script language="javascript">
<!--
function alertDiv(){
//alert (content.innerHTML);
alert (document.getElementById("newDiv").innerHTML);
}
//-->
</script>
<link href="chat1.css" rel="stylesheet" type="text/css" />
</head>
<body onload = 'alertDiv()'>
<div id="newDiv" class="chatWindow" style="margin:200px;">
Hi, all!!!
</div>
</body>
</html>
Also try the file at:
http://raghavan20.allhyper.com/temp.html
Last edited by
raghavan20 on Sun Aug 14, 2005 12:12 pm, edited 1 time in total.
feyd
Neighborhood Spidermoddy
Posts: 31559 Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA
Post
by feyd » Fri Aug 12, 2005 9:33 am
your "host" injects this:
hawleyjr
BeerMod
Posts: 2170 Joined: Tue Jan 13, 2004 4:58 pm
Location: Jax FL & Spokane WA USA
Post
by hawleyjr » Fri Aug 12, 2005 9:34 am
On the site (Your link) The on body tag looks like this:
Code: Select all
//Note there are about 3 spaces before the alertDiv()
<body onload =' alertDiv()'>
Try something like this:
I have no idea if this will fix it or not. just an idea.
raghavan20
DevNet Resident
Posts: 1451 Joined: Sat Jun 11, 2005 6:57 am
Location: London, UK
Contact:
Post
by raghavan20 » Fri Aug 12, 2005 12:40 pm
feyd, what could be the problem if they have the window.onload event to call that function?
What has it go to do with an alert statement?
I actually wanted to read the content in the div,newDiv as soon as the page loads
<body onload = 'alertDiv()'
hi hawleyj, the above is wot I got when I viewed source of the file thats on the site.
feyd
Neighborhood Spidermoddy
Posts: 31559 Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA
Post
by feyd » Fri Aug 12, 2005 12:45 pm
their injected overrides the event. Your code is not run, as you have seen. That line changes the onload event to their function "check_banner"
raghavan20
DevNet Resident
Posts: 1451 Joined: Sat Jun 11, 2005 6:57 am
Location: London, UK
Contact:
Post
by raghavan20 » Fri Aug 12, 2005 1:29 pm
I just have taken out that onload event function and trying to display the innerHTML of the div using alert() which does not happen.
Code: Select all
<!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>Chat Application - Retrieve messages</title>
<script language="javascript">
<!--
alert (document.getElementById("newDiv").innerHTML);
//-->
</script>
<link href="chat1.css" rel="stylesheet" type="text/css" />
</head>
<body>
<div id="newDiv" class="chatWindow" style="margin:200px;">
hi all!!!
</div>
</body>
</html>
PrObLeM
Forum Contributor
Posts: 418 Joined: Sun Mar 07, 2004 2:30 pm
Location: Mesa, AZ
Contact:
Post
by PrObLeM » Fri Aug 12, 2005 1:59 pm
The above code wont work because the div isnt created when you try to call it. YEA ERROR MESSAGES!
but this is one way to fix it
Code: Select all
<!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>Chat Application - Retrieve messages</title>
<script language="javascript">
<!--
function callfunc() {
alert (document.getElementById("newDiv").innerHTML);
}
//-->
</script>
<link href="chat1.css" rel="stylesheet" type="text/css" />
</head>
<body>
<div id="newDiv" class="chatWindow" style="margin:200px;">
hi all!!!
</div>
<script language="javascript">
callfunc();
</script>
</body>
</html>