Click to See Complete Forum and Search --> : Link Script


[RiXak}
09-01-2003, 04:26 PM
Ok, i'm new here, i'm just looking for some help...Hopefully if these forums are as useful as they look i'll be back often...

Here's what i have on a local drive.... A dhtml menu that uses some javascript to clickcopied text.

Example for one of the menus:

dhtmlMenu = new NavBarMenu(110, 187);
dhtmlMenu.addItem(new NavBarMenuItem("<center>ADSL</center>", ""));
dhtmlMenu.addItem(new NavBarMenuItem("1) New Setup", "javascript:copyText(document.all.ADSLSetup);"));
dhtmlMenu.addItem(new NavBarMenuItem("2) Dialer Interferes", "javascript:copyText(document.all.lease);"));
dhtmlMenu.addItem(new NavBarMenuItem("3) 169 IP", "javascript:copyText(document.all.nodata);"));
dhtmlMenu.addItem(new NavBarMenuItem("5) Valid IP No Flow", "javascript:copyText(document.all.vipnf);"));
dhtmlMenu.addItem(new NavBarMenuItem("6) No Sync", "javascript:copyText(document.all.Redext);"));
dhtmlMenu.addItem(new NavBarMenuItem("7) Red Internal", "javascript:copyText(document.all.Redint);"));
dhtmlMenu.addItem(new NavBarMenuItem("8) Slow Speeds", "javascript:copyText(document.all.slow);"));
dhtmlMenu.addItem(new NavBarMenuItem("9) Escalate Info", "javascript:copyText(document.all.Escalate);"));
myNavBar1.addMenu(dhtmlMenu);


The

javascript:copyText(document.all.ADSLSetup)

Part references to the text that i have set to be copied. Now what i wanna do is change it from a copied text function, to a link. This is the script that the copied text runs off, i know i have to replace it with a new script to provide the link function but i don't know where i would find this or how specific the script would have to be....Here's the the clicked copied script:

<script type="text/javascript">
<!--

function copyText( obj ) {

var rng=document.body.createTextRange();

rng.moveToElementText(obj);
rng.scrollIntoView();
rng.select();
rng.execCommand("Copy");
rng.collapse(false);
rng.select();
self.scrollTo(0,0);
}


//-->
</script>


Any idea's how i could mod this?

[RiXak]
09-01-2003, 04:46 PM
<html>
<head>
<title>Shortcut</title>


<script language="JavaScript" src="navcond.js"></script>
<script language="JavaScript">

var myNavBar1 = new NavBar(0);
var dhtmlMenu;

//define menu items (first parameter of NavBarMenu specifies main category width, second specifies sub category width in pixels)
//add more menus simply by adding more "blocks" of same code below

dhtmlMenu = new NavBarMenu(110, 187);
dhtmlMenu.addItem(new NavBarMenuItem("<center>ADSL</center>", ""));
dhtmlMenu.addItem(new NavBarMenuItem("1) New Setup", "javascript:copytext(document.all.ADSLSetup);"));
dhtmlMenu.addItem(new NavBarMenuItem("2) Dialer Interferes", "javascript:copyText(document.all.lease);"));
dhtmlMenu.addItem(new NavBarMenuItem("3) 169 IP", "javascript:copyText(document.all.nodata);"));
dhtmlMenu.addItem(new NavBarMenuItem("5) Valid IP No Flow", "javascript:copyText(document.all.vipnf);"));
dhtmlMenu.addItem(new NavBarMenuItem("6) No Sync", "javascript:copyText(document.all.Redext);"));
dhtmlMenu.addItem(new NavBarMenuItem("7) Red Internal", "javascript:copyText(document.all.Redint);"));
dhtmlMenu.addItem(new NavBarMenuItem("8) Slow Speeds", "javascript:copyText(document.all.slow);"));
dhtmlMenu.addItem(new NavBarMenuItem("9) Escalate Info", "javascript:copyText(document.all.Escalate);"));
myNavBar1.addMenu(dhtmlMenu);

dhtmlMenu = new NavBarMenu(110, 187);
dhtmlMenu.addItem(new NavBarMenuItem("<center>Dial Up</center>", ""));
dhtmlMenu.addItem(new NavBarMenuItem("Create New Dialer", "javascript:copyText(document.all.CreateDialer);"));
dhtmlMenu.addItem(new NavBarMenuItem("Internet Setup Assistant (MAC)", "javascript:copyText(document.all.SAMAC);"));
dhtmlMenu.addItem(new NavBarMenuItem("check modem settings", "javascript:copyText(document.all.chkdial);"));
dhtmlMenu.addItem(new NavBarMenuItem("Password Error", "javascript:copyText(document.all.passError);"));
dhtmlMenu.addItem(new NavBarMenuItem("Telus CD Didn't Work", "javascript:copyText(document.all.teluscd);"));
dhtmlMenu.addItem(new NavBarMenuItem("Idle Disconnect", "javascript:copyText(document.all.medisconnect);"));
myNavBar1.addMenu(dhtmlMenu);

dhtmlMenu = new NavBarMenu(110, 187);
dhtmlMenu.addItem(new NavBarMenuItem("<center>IE / OE</center>", ""));
dhtmlMenu.addItem(new NavBarMenuItem("Internet Connection Wizard", "javascript:copyText(document.all.inetwiznocw);"));
dhtmlMenu.addItem(new NavBarMenuItem("E-Remove Mail", "javascript:copyText(document.all.slowEmail);"));
dhtmlMenu.addItem(new NavBarMenuItem("Create OE Account", "javascript:copyText(document.all.createOEAccount);"));
myNavBar1.addMenu(dhtmlMenu);


dhtmlMenu = new NavBarMenu(110, 187);
dhtmlMenu.addItem(new NavBarMenuItem("<center>MISC.</center>", ""));
dhtmlMenu.addItem(new NavBarMenuItem("Manual Account Setup", "javascript:copyText(document.all.CSSetup);"));
dhtmlMenu.addItem(new NavBarMenuItem("OCA Prov.", "javascript:copyText(document.all.ocaprov);"));
dhtmlMenu.addItem(new NavBarMenuItem("Comments Template", "javascript:copyText(document.all.comments);"));
myNavBar1.addMenu(dhtmlMenu);


//set menu colors
myNavBar1.setColors("black", "white", "gray", "gray", "#000000", "black", "gray", "#000000", "#ff9933");

//uncomment below line to center the menu (valid values are "left", "center", and "right"
myNavBar1.setAlign("right")

var fullWidth;

function init() {

// Get width of window, need to account for scrollbar width in Netscape.

fullWidth = getWindowWidth()
- (isMinNS4 && getWindowHeight() < getPageHeight() ? 0 : 20);

myNavBar1.resize(fullWidth);
myNavBar1.create();
myNavBar1.setzIndex(2);
}
</script>

<script type="text/javascript">
<!--

function copyText( obj ) {

var rng=document.body.createTextRange();

rng.moveToElementText(obj);
rng.scrollIntoView();
rng.select();
rng.execCommand("Copy");
rng.collapse(false);
rng.select();
self.scrollTo(0,0);
}


//-->
</script>


<SCRIPT LANGUAGE="JavaScript">
function getonme() {
el = event.srcElement ;
if (el.getAttribute("litUp1") != null) {
el.className = "onme1" ;
}
}

function getoffme() {
el = event.srcElement ;
if (el.getAttribute("litUp1") != null) {
el.className = "offme";
}
}

document.onmouseover = getonme ;
document.onmouseout = getoffme ;
</SCRIPT>
<STYLE TYPE="text/css">

<STYLE type="text/css">
<!--
.roll { font-family:Arial; font-size:10pt; font-style:normal; font-weight:bold; letter-spacing:normal; text-decoration:none; color:white; }
A.roll:hover { text-decoration:yes; text-transform:none; color:black; background:white; }
-->
</STYLE>

</head>

[RiXak]
09-01-2003, 05:05 PM
Ok, I noticed i wasn't getting any help so i uploaded the page so it can be viewed to http://www28.brinkster.com/wrukus/java/init.html

If you click on anything in the nav bar it click copies to your clip board. I want to change that function to open a new link window.


PLEEEEEEEEEASE help me.

David Harrison
09-01-2003, 05:22 PM
OK, it's important that you know that I don't know how your code works because I haven't read through it, and with any luck I won't have to. But it seems that if you want to get your menu items to act as links you should change this:

dhtmlMenu.addItem(new NavBarMenuItem("1) New Setup", "javascript:copytext(document.all.ADSLSetup);"));

into something like this:

dhtmlMenu.addItem(new NavBarMenuItem("1) New Setup", "http://www.w3.org/"));

[RiXak]
09-01-2003, 05:30 PM
Ok, Thanks.

So you think i should just delete the copyText script all together? I'm trying it now.

[RiXak]
09-01-2003, 05:36 PM
It looks as if it works, however it opens in the same window and attempts to open the url as an extension of the root, this may be different when online....

I tried target='blank' but that doesn't work. Would you suggest an Onclick= Approach?

David Harrison
09-02-2003, 01:23 PM
Change target="blank" to target="_blank" and see what happens.