/    Sign up×
Community /Pin to ProfileBookmark

javascript conflict – help please

Hi – my first post – hope I’m not too dumb – please forgive me if so.

I have a problem with two javascript conflicting on my page.

I already have a javascript navigation menu. I now want to add a popup window, and I found a scipt from The Javascript source, but it doesn’t work.

If I remove the code for my nav menu, then the popup works fine, so clearly the two are conflicting in some way. Can I stop this happening?

code for the nav menu is:

<script language=”javascript”>
var NC6=(navigator.userAgent.indexOf(“Netscape6”)>0)?true:false;
var IE=(document.all)?true:false;
if(IE){
document.write(“<script language=”javascript” src=”menu.js”></script>”);
}else if(NC6){
document.write(“<script language=”javascript” src=”NCmenu.js”></script>”);
}
</script>

code for the popup window is:

<SCRIPT LANGUAGE=”JavaScript”>
<!– Idea by: Nic Wolfe ([email protected]) –>
<!– Web URL: [url]http://fineline.xs.mw[/url] –>

<!– This script and many more are available free online at –>
<!– The JavaScript Source!! [url]http://javascript.internet.com[/url] –>

<!– Begin
function popUp(URL) {
day = new Date();
id = day.getTime();
eval(“page” + id + ” = window.open(URL, ‘” + id + “‘, ‘toolbar=0,scrollbars=0,location=0,statusbar=0,menubar=0,resizable=0,width=200,height=200,left = 300,top = 200’);”);
}
// End –>
</script>

within the head tags and also

<BODY onLoad=”javascript:popUp(‘http://www.mcjs.co.uk/popup1.htm‘)”>

Thanks very much for your help

to post a comment
JavaScript

10 Comments(s)

Copy linkTweet thisAlerts:
@Mr_JFeb 24.2004 — Try this


[SIZE=1]function popUp(URL) {

[B]window.open(URL,'','toolbar=0,scrollbars=0,location=0,statusbar=0,men

ubar=0,resizable=0,width=200,height=200,left = 300,top = 200')[/B]


}









<BODY onload="#null" onclick="('http://www.mcjs.co.uk/popup1.htm')">









[/SIZE]


The embolded line is one continuous line
Copy linkTweet thisAlerts:
@elbandito999authorFeb 24.2004 — hmmm. doesn't even work without the nav menu now.

is there a bug in the above?
Copy linkTweet thisAlerts:
@Mr_JFeb 24.2004 — Oops, sorry, I made a mega boo boo with the body tag onload try this


<script>

function popUp(URL) {

window.open(URL,'','toolbar=0,scrollbars=0,location=0,statusbar=0,menubar=0,resizable=0,width=200,height=200,left = 300,top = 200')

}

</script>


<BODY onload="popUp('http://www.mcjs.co.uk/popup1.htm')">
Copy linkTweet thisAlerts:
@elbandito999authorFeb 25.2004 — thanks for your help - it does now work without the nav bar, but still doesn't with it.

is this a common problem?
Copy linkTweet thisAlerts:
@Mr_JFeb 25.2004 — Lets try changing the function name because if "popUp" is already being used in the menu script it would cause a problem


<script>

function my_popup(URL) {

window. open(URL,'','toolbar=0,scrollbars=0,location=0,sta

tusbar=0,menubar=0,resizable=0,width=200,height=20

0,left = 300,top = 200')

}

</script>


<BODY onload="my_popup('http://www.mcjs.co.uk/popup1.htm')">

This forum is not rendering the post correctly the window statement should be all one line
Copy linkTweet thisAlerts:
@elbandito999authorFeb 25.2004 — hum. still the same problem.

anyone know a different way of making a pop-up window without using javascript?
Copy linkTweet thisAlerts:
@Mr_JFeb 25.2004 — Are you trying to open a new window using a link in the menu?
Copy linkTweet thisAlerts:
@elbandito999authorFeb 25.2004 — yes & no - some of the links did open a new window, but i've changed it so they don't and... it still doesn't work! good idea though - i really thought that was going to work ?

the page is

http://www.mcjs.co.uk/englishlinks.htm

The java menu was done using a program called webmenushop. it makes a file called menu.js which i've attached as a txt file.

i really apprecaiye your help with this - thanks.

[upl-file uuid=ac59646e-6546-47d4-9c7a-6ef8cb7e5a50 size=17kB]menu.txt[/upl-file]
Copy linkTweet thisAlerts:
@Mr_JFeb 25.2004 — In the menu.js file there is "window.onload=mfixSize" this is where the problem is.

Comment out this statement in the js file and add it to the onload in the BODY tag like so


onload="popUp('http://www.mcjs.co.uk/popup1.htm');mfixSize()"

Just in case .....

I have posted the amended js file for you to try, when you download it save it as a .js file

Your popup worked when I tried it

Your popup says

Have you bought

your tickets for

three cheers

for

mrs butler!

yet

[upl-file uuid=b6c09ffb-545e-4878-a207-ce52ba67bd5f size=17kB]menu.txt[/upl-file]
Copy linkTweet thisAlerts:
@elbandito999authorFeb 25.2004 — fantastic - its now working!

i'm eternally grateful - thanks so much!
×

Success!

Help @elbandito999 spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 6.17,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @nearjob,
tipped: article
amount: 1000 SATS,

tipper: @meenaratha,
tipped: article
amount: 1000 SATS,

tipper: @meenaratha,
tipped: article
amount: 1000 SATS,
)...