A Digital Age Deserves A Digital Leader

Urgent - Help with HTML or JavaScript

Urgent - Help with HTML or JavaScript

Postby Dave-Combinatrix » Wed Jun 09, 2004 1:17 pm

Is there anyone out there that can help me with a problem.:question

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.:bashhead
"parent.frames.locations is null or not an object" :no


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.
PRO Level 2
User avatar
Posts: 27
Joined: Tue May 11, 2004 11:20 am
Location: Dorset UK

Postby twhite56 » Wed Jun 09, 2004 1:55 pm

I have no idea about the first part...but for the second part about loading a page into another page...did you try an iframe? The frame would load once you opened the page. :yesnod:
PROfessional Member
User avatar
Posts: 373
Joined: Sun Jan 11, 2004 12:24 am

Postby Dave-Combinatrix » Wed Jun 09, 2004 2:37 pm

twhite56

Thanks I will give that a try. ^*^
PRO Level 2
User avatar
Posts: 27
Joined: Tue May 11, 2004 11:20 am
Location: Dorset UK

Postby jbullard » Wed Jun 16, 2004 1:11 am

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
VP - Software
User avatar
Posts: 3653
Joined: Sun Jun 06, 2004 10:17 pm
Location: Utah
Real Name: Jason Bullard

Postby Brainhead » Wed Jun 16, 2004 9:22 am

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.
PRO Level 2
Posts: 13
Joined: Tue Apr 13, 2004 1:14 pm
Location: Belgi

Postby Dave-Combinatrix » Wed Jun 16, 2004 12:17 pm

jbullard writes:
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. ^*^
PRO Level 2
User avatar
Posts: 27
Joined: Tue May 11, 2004 11:20 am
Location: Dorset UK

Postby Dave-Combinatrix » Wed Jun 16, 2004 12:28 pm

Brainhead writes:
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, :clobber: maybe the function name can't be the same as a parameter name.

I going to go and try it. :runaway:

Thanks for the help. I will let you know the results. ^*^
PRO Level 2
User avatar
Posts: 27
Joined: Tue May 11, 2004 11:20 am
Location: Dorset UK

Postby Hugo van Dijk » Wed Jun 16, 2004 12:35 pm

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

:yesnod: ^*^
PROfessional Member
User avatar
Posts: 2073
Joined: Sat May 01, 2004 7:07 pm
Location: Netherlands

Postby jbullard » Wed Jun 16, 2004 8:02 pm

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
VP - Software
User avatar
Posts: 3653
Joined: Sun Jun 06, 2004 10:17 pm
Location: Utah
Real Name: Jason Bullard

Postby Dave-Combinatrix » Sun Jun 27, 2004 9:33 pm

jbullard writes:
.... 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. :notworthy
PRO Level 2
User avatar
Posts: 27
Joined: Tue May 11, 2004 11:20 am
Location: Dorset UK

Return to HTML, CSS, and Scripts

Who is online

Users browsing this forum: No registered users and 12 guests

cron
cron