|
-
Aug 7th, 2005, 05:11 PM
#1
Thread Starter
Hyperactive Member
Crappy Javascript
Here is the page that I am making below:
Code:
<html>
<head>
<title>~~~~***Melissa***~~~~</title>
<script language="javascript">
function show_page(page_number)
{
//Change the source of the inline frame
if (page_number == 1)
Main.src="MelissaHome.html";
if (page_number == 2)
Main.src="MelissaPoems.html";
if (page_number == 3)
Main.src="MelissaMusic.html";
if (page_number == 4)
Main.src="MelissaArt.html";
}
</script>
</head>
<body style="background-image:url(MelissaInterface.jpg); background-repeat:no-repeat; background-position:center; background-color:white;">
<!-- The navigation table -->
<table border="0" cellpadding="5" cellspacing="0" cols="1" style="width:188px; height:310px; position:absolute; top:290px; left:153px;">
<tr>
<td align="center"><input id="cmdHome" type="button" value="Home" onclick="show_page(1)" /></td>
</tr>
<tr>
<td align="center"><input id="cmdPoems" type="button" value="Poems" /></td>
</tr>
<tr>
<td align="center"><input id="cmdMusic" type="button" value="My Music" /></td>
</tr>
<tr>
<td align="center"><input id="cmdArt" type="button" value="My Art" /></td>
</tr>
</table>
<!-- The inline frame for the actual pages with content -->
<iframe name="Main" frameborder="0" src="" style="width:460px; height:335px; position:absolute; top:200px; left:400px;"></iframe>
</body>
</html>
In the ONCLICK event on the first button, did I script that right because it's not working at all. The source of the inline frame doesn't change. It just stays blank. Or did I script the function wrong? HELP!!!!!!!!
-
Aug 7th, 2005, 10:48 PM
#2
PowerPoster
Re: Crappy Javascript
Location
.replace(URL) - Requires a URL as a parameter. It loads the document at the URL on top of the current document. A new entry entry is not placed in the history object.
So I believe the javascript to get to the iframe is something like...
document.getElementById('hiddenframe').location.replace("newpage");
My suggestion is to download FireFox, and check out the JavaScript console, it gives pretty good error messages compared to IE.
-
Aug 7th, 2005, 11:26 PM
#3
Thread Starter
Hyperactive Member
Re: Crappy Javascript
I downloaded FireFox and looked at the JavaScript Console (which was a very helpful idea so thank you for that) but it says that my iframe has no properties. It's almost like it don't even exist. I get the following error:
document.getElementById(Main).location has no properties
I change the code only for the first button and it looks like this:
Code:
document.getElementById('Main').location.replace("MelissaHome.html");
What the heck is going on here?
EDIT:
I removed the code and went back to the original code I had before and I clicked the button and checked the JavaScript console. It didn't have any errors but no sites were appearing in the iframe.
-
Aug 7th, 2005, 11:33 PM
#4
PowerPoster
Re: Crappy Javascript
Make sure your iframe has a id="Main".
You might be able to just do,
document.Main.location.replace(..) without giving it an id, but I'm not sure to be honest, the structure of documents was always really confusing.
-
Aug 7th, 2005, 11:42 PM
#5
Thread Starter
Hyperactive Member
Re: Crappy Javascript
Thanks for you help through this entire thing by the way.
Yeah I did that but then I found something else funny. When I set a source page for the iframe in src attribute of the iframe tag, the source page won't even show up! The source file direction is correct but nothing is working.
-
Aug 8th, 2005, 12:11 AM
#6
Thread Starter
Hyperactive Member
Re: Crappy Javascript
Don't worry about it anymore. I quit. I tried retyping the code, giving it an ID, using the getElementById() method, everything. Nothing is working. It's almost like the parser isn't even picking it up as an object.
-
Aug 8th, 2005, 12:13 AM
#7
PowerPoster
Re: Crappy Javascript
Just doing alittle reading, you may be able to use the src property, but try giving it the full path to the file (www.server.blah/blah/Melissa.html).
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|