/    Sign up×
Community /Pin to ProfileBookmark

Newbie having Javascript problems

Hi All,

I am stuck. I am not actually writing any code but I am
inserting Javascript into my web page from resources on the net. I have a Dynamic Drive fold out Menu & a javascript pop up message on my page. Both scripts work fine individually but they will not work together. I get error’s on page warnings and the menu does not appear.

The pop up code is;
——————————————————————-

<HEAD>
<script type=”text/javascript”>
<!–
/*
This code is from Dynamic Web Coding
at [url]http://www.dyn-web.com/[/url]
Copyright 2001-2 by Sharon Paine
See Terms of Use at [url]http://www.dyn-web.com/bus/terms.html[/url]
Permission granted to use this code
as long as this entire notice is included.
*
/

// dw_tooltip.js contains onresize and onload handlers
// Put tooltip div and script tags for external js files at end of document

// avoid error of passing event object from link in older browsers
if (!document.getElementById && !document.all && !document.layers)
event = “”;

function hideTip() {} // avoid errors until loaded

var tooltip;
function doTooltip(evt,txt) {
if (!tooltip) return;
var cntnt = wrapTip(txt);
goTooltip(evt,cntnt);
}

// wrap tip content for formatting
function wrapTip(txt) {
var cntnt = “”;
if (document.layers) {
cntnt = ‘<table bgcolor=”‘ + tipBorderColor + ‘” width=”‘ + tipWidth + ‘” cellspacing=”0″ cellpadding=”‘ + tipBorderWidth + ‘” border=”0″><tr><td><table bgcolor=”‘ + tipBgColor + ‘” width=”100%” cellspacing=”0″ cellpadding=”‘ + tipPadding + ‘” border=”0″><tr><td><div style=”font-family:’ + tipFontFamily + ‘; font-size:’ + tipFontSize + ‘; color:’ + tipFontColor + ‘;”>’ + txt + ‘</div></td></tr></table></td></tr></table>’;
} else cntnt = txt;
return cntnt;
}

/////////////////////// CUSTOMIZE TOOLTIP HERE ///////////////////////
// settings for tooltip (don’t remove any of these variables!)

// Do you want tooltip to move when mouse moves over link?
var tipFollowMouse = true;
// be sure to set tooltip width wide enough for widest image!
// take into account border and padding
var tipWidth = 240; // width of tooltip in pixels

// how far from mouse to show tooltip
var tipOffX = 8; // horizontal offset
var tipOffY = 12; // vertical offset

var tipFontFamily = “Verdana, arial, helvetica, sans-serif”;
var tipFontSize = “11px”; // string with pixels or points (px or pt)
// tooltip content line-height
var tipLineHeight = 1.2; // number (recommend 1 to 1.3)
var tipFontColor = “#000000”;
var tipBgColor = “#d6e4fc”; // tooltip background color
// background image for tooltip (leave empty string if no bg image)
var tipBgImg = “”;
// “breathing room” around tooltip content
var tipPadding = 4; // integer (pixel value)

// leave a color in here even if you don’t want a border
var tipBorderColor = “#000080”;

// if you don’t want a border, set tipBorderWidth to 0
var tipBorderWidth = 1; // integer (pixel value)

// if you don’t want a border, set tipBorderStyle to “none”
// options for border style: “none”, “solid”, “ridge”, “outset”,
// “inset”, “groove”, “double”, “dashed”
// (they won’t look the same in all browsers though!)
var tipBorderStyle = “groove”;

// NOTES:
// Adding a large amount of padding and thick borders will
// result in a noticeable difference in the tooltip width
// between browsers that are standards-compliant and those
// that are not. For best results, keep these values small.
// Background image, line-height and border style settings
// for the tooltip are not supported for ns4.

// preload images to be placed in tooltip
// place your images in this array
var imgAr = new Array(
“images/sm-duck.gif”
);

if (document.images) {
var imgs = new Array();
for (var i=0; i<imgAr.length; i++) {
imgs[i] = new Image();
imgs[i].src = imgAr[i];
}
}

// variables for tooltip content
// name them whatever you want, add as many as you need
var tip1 = “An example link for the tooltip using plain text.”;
var tip2 = ‘<img src=”images/sm-duck.gif” width=”90″ height=”44″ alt=”” border=”0″><div class=”tp1″>Images and text can go together in a tooltip.</div>’;
var tip3 = ‘A link to Dynamic Web Coding would be appreciated!’;
//–>
</script>
</HEAD>

<BODY>
<td class=”tiny”><a href=”your.html” onmouseover=”doTooltip(event,tip1)” onmouseout=”hideTip()”>link</a></td>

<div id=”tipDiv” style=”position:absolute; visibility:hidden; left:0; top:0; z-index:1000″></div>
<script src=”dw_core.js” type=”text/javascript”></script>
<script src=”dw_util.js” type=”text/javascript”></script>
<script src=”dw_tooltip.js” type=”text/javascript”></script>
<div id=”pLayer” style=”position:absolute; width:200; visibility:hidden; z-index:200″>
</div>

</BODY>
———————————————————————


The Menu code is;

<BODY>
<script type=’text/javascript’>

//HV Menu v5.411- by Ger Versluis ([url]http://www.burmees.nl/[/url])
//Submitted to Dynamic Drive ([url]http://www.dynamicdrive.com[/url])
//Visit [url]http://www.dynamicdrive.com[/url] for this script and more

function Go(){return}

</script>
<script type=’text/javascript’ src=’exmplmenu_var.js’></script>
<script type=’text/javascript’ src=’menu_com.js’></script>
<noscript>Your browser does not support script</noscript>

</BODY>
——————————————————————–

If it is more help the URL is;
[url]http://www.artdiscount.com/acatalog/temp_page2.htm[/url]

The pop up message is working but the menu isn’t.

Many thanks in advance.

Regards

Stevie.

to post a comment
JavaScript

4 Comments(s)

Copy linkTweet thisAlerts:
@96turnerriDec 01.2003 — this will be because you have two variables / functions called the same, you will need to change one of them to something else
Copy linkTweet thisAlerts:
@StevieauthorDec 02.2003 — Thanks 96turnerri,

I am completely new to javascript, which are the variables that

are the same?

Sorry to bug you.

Many thanks

Stevie
Copy linkTweet thisAlerts:
@PittimannDec 02.2003 — Hi!

Actually I did'nt check all the five .js files intensiveley. But at first sight, no variables or functions are having the same name.

I got the stuff to work like that (I deleted most of the comments to make the code a bit shorter):
[code=php]
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
<meta name="GENERATOR" content="Microsoft FrontPage 4.0">
<meta name="ProgId" content="FrontPage.Editor.Document">
<title>HV Menu example</title>
<script type="text/javascript">
<!--
if (!document.getElementById && !document.all && !document.layers)
event = "";
function hideTip() {} // avoid errors until loaded
var tooltip;
function doTooltip(evt,txt) {
if (!tooltip) return;
var cntnt = wrapTip(txt);
goTooltip(evt,cntnt);
}
function wrapTip(txt) {
var cntnt = "";
if (document.layers) {
cntnt = '<table bgcolor="' + tipBorderColor + '" width="' + tipWidth + '" cellspacing="0" cellpadding="' + tipBorderWidth + '" border="0"><tr><td><table bgcolor="' + tipBgColor + '" width="100%" cellspacing="0" cellpadding="' + tipPadding + '" border="0"><tr><td><div style="font-family:' + tipFontFamily + '; font-size:' + tipFontSize + '; color:' + tipFontColor + ';">' + txt + '</div></td></tr></table></td></tr></table>';
} else cntnt = txt;
return cntnt;
}
var tipFollowMouse = true;
var tipWidth = 240; // width of tooltip in pixels
var tipOffX = 8; // horizontal offset
var tipOffY = 12; // vertical offset
var tipFontFamily = "Verdana, arial, helvetica, sans-serif";
var tipFontSize = "11px"; // string with pixels or points (px or pt)
var tipLineHeight = 1.2; // number (recommend 1 to 1.3)
var tipFontColor = "#000000";
var tipBgColor = "#d6e4fc"; // tooltip background color
var tipBgImg = "";
var tipPadding = 4; // integer (pixel value)
var tipBorderColor = "#000080";
var tipBorderWidth = 1; // integer (pixel value)
var tipBorderStyle = "groove";
var imgAr = new Array(
"images/sm-duck.gif"
);
if (document.images) {
var imgs = new Array();
for (var i=0; i<imgAr.length; i++) {
imgs[i] = new Image();
imgs[i].src = imgAr[i];
}
}
var tip1 = "An example link for the tooltip using plain text.";
var tip2 = '<img src="images/sm-duck.gif" width="90" height="44" alt="" border="0"><div class="tp1">Images and text can go together in a tooltip.</div>';
var tip3 = 'A link to Dynamic Web Coding would be appreciated!';
//-->
</script>
</head>
<body>
<div id="tipDiv" style="position:absolute; visibility:hidden; left:0; top:0; z-index:1000"></div>
<script src="dw_core.js" type="text/javascript"></script>
<script src="dw_util.js" type="text/javascript"></script>
<script src="dw_tooltip.js" type="text/javascript"></script>
<div id="pLayer" style="position:absolute; width:200; visibility:hidden; z-index:200">
</div>
<script type='text/javascript'>
function Go(){return}
</script>
<script type='text/javascript' src='exmplmenu_var.js'></script>
<script type='text/javascript' src='menu_com.js'></script>
<noscript>Your browser does not support script</noscript>
<td class="tiny"><a href="your.html" onmouseover="doTooltip(event,tip1)" onmouseout="hideTip()">link</a></td>
</BODY>
</html>
[/code]

Please note, that I put all necessary files in one folder.

Cheers - Pit
Copy linkTweet thisAlerts:
@StevieauthorDec 02.2003 — Cheers Pittimann!

I have copied your code into the page and it works great.

I don't know what you did but I'm glad it now works!

Much appreciated & many thanks.

Regards

Stevie.
×

Success!

Help @Stevie 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 5.4,
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: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,

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