Click to See Complete Forum and Search --> : Newbie having problems


Stevie
12-01-2003, 07:36 AM
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.

I will supply code if needed but is this a common problem?

Please help!

Thanks in advance.

Stevie.

Gollum
12-01-2003, 07:43 AM
Could be the two scripts are declaring things with common names. To be sure, could you post the code (or a URL)?

clairec666
12-01-2003, 07:44 AM
Alot of the time, two seperate codes on the same page cause problems........... since you can have two different variables in the two scripts which have been given the same name. It would be useful if you posted the script here. I'll be on here a bit later (1 hour?) if nobody else has come to your rescue by then!!

Claire

Stevie
12-01-2003, 08:33 AM
Hi,

Thanks for your quick replies.

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

<HEAD>
<script type="text/javascript">
<!--
/*
This code is from Dynamic Web Coding
at http://www.dyn-web.com/
Copyright 2001-2 by Sharon Paine
See Terms of Use at http://www.dyn-web.com/bus/terms.html
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 (http://www.burmees.nl/)
//Submitted to Dynamic Drive (http://www.dynamicdrive.com)
//Visit http://www.dynamicdrive.com 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;
http://www.artdiscount.com/acatalog/temp_page2.htm

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

Many thanks again for your help.

Regards

Stevie.

Gollum
12-01-2003, 09:10 AM
Stevie,
I don't think the two scripts should interfere too much.
Your problem (at the URL you posted) seems to be that the function popup() is not being initialised properly.
I figure if you insert a line of code after the function like this...
popup(null);

It should all start working

Stevie
12-01-2003, 09:22 AM
Sorry Gollum,

I can't find the code - popup() in the document?


Regards

Stevie