Urgent - Help with HTML or JavaScript
10 posts
• Page 1 of 1
Urgent - Help with HTML or JavaScript
Is there anyone out there that can help me with a problem.
I am trying to get a link on my web page to load a new menu page (menu bar.html) and a new main page (main.html) at the same time.
This is the <script> from the top of the menu bar page:
- Code: Select all
<script language="JavaScript"><!--
function New_Arrivals(Menu2,New_Arrivals) {
parent.MenuBar.location.href = Menu2.html;
parent.Main.location.href = New_Arrivals.html;
}
// end of script -->
</script>
(This is the script template I was supplied with)
- Code: Select all
<script language="JavaScript"><!--
function functionName(fileName1,fileName2) {
parent.frameName1.location.href = fileName1;
parent.frameName2.location.href = fileName2;
}
//--></script>
This is one of the buttons in the menu bar page:
- Code: Select all
<!--- Menu Item 2 -->
<!--- New Arrivals --->
<!--- Menu Change--->
<a href="javascript:New_Arrivals('Menu2.html','New_Arrivals.html')"
onMouseOver="if (VersionNav(3.0,4.0)) img2.src='Buttons (Daves)/New Arrivals-Down.gif'"
onMouseOut="img2.src='Buttons (Daves)/New Arrivals-Up.gif'" >
<img name="img2" WIDTH=100 HEIGHT=75 border=0 alt="Click Here for New Arrivals page"
src="Buttons (Daves)/New Arrivals-Up.gif"
onLoad="tempImg=new Image(0,0); tempImg.src='Buttons(Daves)/New Arrivals-Down.gif'"></a>
The mouse in and out works OK, but when clicking on the button it will load the main page, but not the new menu.
Basically, I just want a button to load a new menu and a new main page. I do not care if it is javascript or html, as long as it works.
I have tried using JavaScript that I got off another site, but I keep getting errors. Does the script have to be in a certain page?
At the moment I have everything on the MenuBar page.
If it does need to be on another page, how do I call the function from there?
Whenever it is clicked on it produces an error.
"parent.frames.locations is null or not an object"
I would also like to know how to load a page direct on opening.
So when index.html loads it will automatically load another file into it (main.html).
I know I have to use the 'onLoad' but I can't work out the rest without getting errors.
Thanks to anyone that can offer assistance
Please treat me as thick, as I do not have much experiance with JavaScript and what goes where and on what pages.
Last edited by Dave-Combinatrix on Sat Jun 12, 2004 8:09 pm, edited 1 time in total.
- Dave-Combinatrix
- Posts: 27
- Joined: Tue May 11, 2004 11:20 am
- Location: Dorset UK
Your code:
<script language="JavaScript"><!--
function New_Arrivals(Menu2,New_Arrivals) {
parent.MenuBar.location.href = Menu2.html;
parent.Main.location.href = New_Arrivals.html;
}
// end of script -->
</script>
There are 2 vars: Menu2.html is one of them but where can I found this var again? I think you need to correct this to just Menu2, this is the paramname of your function. Javascript doesn't give an error if you use a variable that doesn't exist.
<script language="JavaScript"><!--
function New_Arrivals(Menu2,New_Arrivals) {
parent.MenuBar.location.href = Menu2.html;
parent.Main.location.href = New_Arrivals.html;
}
// end of script -->
</script>
There are 2 vars: Menu2.html is one of them but where can I found this var again? I think you need to correct this to just Menu2, this is the paramname of your function. Javascript doesn't give an error if you use a variable that doesn't exist.
jbullard writes:
The onclick action is done by the href link to the script function which in turn is supposed to call and load the two frames.
Thanks for the idea. But I have already tried that before having to turn to JavaScript. It appears that the only way to load two frames at once is through JavaSript unfortunately.
Thanks anyway.
Where is your onclick tag. I see a onmouseover and an onmouseout but no onclick. I am not to familiar with javascript but this may be what your missing.
Jason
The onclick action is done by the href link to the script function which in turn is supposed to call and load the two frames.
Thanks for the idea. But I have already tried that before having to turn to JavaScript. It appears that the only way to load two frames at once is through JavaSript unfortunately.
Thanks anyway.
- Dave-Combinatrix
- Posts: 27
- Joined: Tue May 11, 2004 11:20 am
- Location: Dorset UK
Brainhead writes:
The two vars are Menu2.html and New_Arrivals.html, the function name is New_Arrivals (I have also tried it with out the '_' just in case.) Both file are in the root directory. I have only changed the files that were suggested by the base example.
I have tried it with just one file as well and it still didn't work.
Hey I have just had a thought, maybe the function name can't be the same as a parameter name.
I going to go and try it.
Thanks for the help. I will let you know the results.
Your code:
<script language="JavaScript"><!--
function New_Arrivals(Menu2,New_Arrivals) {
parent.MenuBar.location.href = Menu2.html;
parent.Main.location.href = New_Arrivals.html;
}
// end of script -->
</script>
There are 2 vars: Menu2.html is one of them but where can I found this var again? I think you need to correct this to just Menu2, this is the paramname of your function. Javascript doesn't give an error if you use a variable that doesn't exist.
The two vars are Menu2.html and New_Arrivals.html, the function name is New_Arrivals (I have also tried it with out the '_' just in case.) Both file are in the root directory. I have only changed the files that were suggested by the base example.
I have tried it with just one file as well and it still didn't work.
Hey I have just had a thought, maybe the function name can't be the same as a parameter name.
I going to go and try it.
Thanks for the help. I will let you know the results.
- Dave-Combinatrix
- Posts: 27
- Joined: Tue May 11, 2004 11:20 am
- Location: Dorset UK
i had latly problemms with my browser after testing a php/javascript my browser give errors and on my friends pc it worked
so sometimes the browser is the problemm
so sometimes the browser is the problemm
- Hugo van Dijk
- PROfessional Member
- Posts: 2073
- Joined: Sat May 01, 2004 7:07 pm
- Location: Netherlands
Why don't you use an body onload tag in each page that you want to have the menu frame change. Like this:
frame 1(menu 1)
frame 2---->frame 3
---Change frame 1 to frame 4(menu 2)
This type of function also helps when someone types in your url with frame 2 and it automatically inserts the frame 4.
This is just a thought.
Jason
frame 1(menu 1)
frame 2---->frame 3
---Change frame 1 to frame 4(menu 2)
This type of function also helps when someone types in your url with frame 2 and it automatically inserts the frame 4.
This is just a thought.
Jason
- jbullard
- VP - Software
- Posts: 3653
- Joined: Sun Jun 06, 2004 10:17 pm
- Location: Utah
- Real Name: Jason Bullard
jbullard writes:
OK, first I would like to thank everyone that has offered answers.
I have at last done it.
In the end I used jasons advice, after spending a long time on the javascript, I gave up and moved to the HTML onClick option.
After a lot of alterations, I actually managed to get it to work.
I will have to spend a lot more time on the javascript before trying to use it again.
Many thanks to everyone.
.... Where is your onclick tag. I see a onmouseover and an onmouseout but no onclick. I am not to familiar with javascript but this may be what your missing.
OK, first I would like to thank everyone that has offered answers.
I have at last done it.
In the end I used jasons advice, after spending a long time on the javascript, I gave up and moved to the HTML onClick option.
After a lot of alterations, I actually managed to get it to work.
I will have to spend a lot more time on the javascript before trying to use it again.
Many thanks to everyone.
- Dave-Combinatrix
- Posts: 27
- Joined: Tue May 11, 2004 11:20 am
- Location: Dorset UK
10 posts
• Page 1 of 1
Return to HTML, CSS, and Scripts
Who is online
Users browsing this forum: No registered users and 12 guests