PDA

View Full Version : creating a shortcut script?


CarpeNoctem
08-02-2003, 02:22 PM
currently, i use a mouseover on all of the links on my site, but not only does it take up a lot of room (coding wise) and it creates a longer load time for the page, but it it simply just a pain in the bum, and 1 wrong thing, ruins it all.

say i have the following code:

<a href="berkowitz.html"
onMouseOut="window.status=''; return true;"
onMouseOver="window.status='The Son of Sam'; return true">David Berkowitz</a>

is there a way that i can create a script in which i would enter the "berkowitz.html" and "Son of Sam" and then "David Berkowitz" and it would display it properly, or should i just stick to writing out that long code for every link.

if you are confused by what i am asking, i am sorry, i dont know the proper terminology, but i think i got my point across?

scoutt
08-02-2003, 04:02 PM
nope not with mouseovers. you can create a external script but you still have mouseovers in the links or a functions to call them that would be just as long as those in the first place.

n8thegreat
08-02-2003, 07:25 PM
sure there is, i could make a script that could take whatever is in the title attribute of the anchor and make it display in the status bar. its really not hard, ill post it up here in a little bit

n8thegreat
08-02-2003, 07:56 PM
just make a js file with this in it

function status_init() {
var a, stat;
var anchors = document.getElementsByTagName("a");
for ( var i=0; (a=anchors[i]); i++ ) {
stat = a.title;
if ( stat != "" && stat != null ) {
a.onmouseover = swap_it;
a.onmouseout = clear_it;
}
}
}
function swap_it() {
window.status = this.title;
return true;
}
function clear_it() {
window.status = "";
return true;
}


then in the page do <body onload="status_init()"> and every anchor that has a title attribute will have its title show up in the status bar, so you dont have to do countless onmosueover's and stuff :)


also guys, i tried doing document.anchors to return all the anchor tags, but for some reason it didnt return anything, does anyone know why?

CarpeNoctem
08-03-2003, 12:48 PM
ok,

so say for example that i have <a href="bundy.html">Ted Bundy</a>

using that JS it will just show "Ted Bundy" in the bottom left of the screen?


where do i put the tag to call up the JS script?

n8thegreat
08-03-2003, 03:56 PM
no you would do
<a href="blahblah" title="Ted Bundy">Brother of Al</a> and Ted Bundy would show up in the status bar

just in the head section do <script src="urltothejsfile" type="text/javascript"></script> and then do <body onload="status_init()">, otherwise there is no javascript call.

Jon Hanlon
08-04-2003, 02:59 AM
i tried doing document.anchors to return all the anchor tags, but for some reason it didnt return anything, does anyone know why?


The anchors collection is a read-only collection of every anchor that has an id and/or name.

http://msdn.microsoft.com/workshop/author/dhtml/reference/collections/anchors.asp

n8thegreat
08-04-2003, 10:01 AM
ahh, i see, i just assumed it worked like document.images, but its a little different

schnitzel_21st
01-08-2004, 03:38 PM
i made this, it is javascript, where you can change the mouse over name by simply changing the verible:

<body>
<script>
var control = "Welcome To My Website"
var index = "Index"
</script>
<a onMouseOver="window.status=index;return true" onMouseOut="window.status=control;return true" href="../default.htm">Index</a>
</body>


.::14 YEAR OLD::.

Matt001
01-11-2004, 11:27 AM
Theres a problem with your script, I have a right click script on my site and if you right click on the link it shows the url address.
Can someone help me so it doesnt show the url on the status bar.

Example Page (http://www.undeadguild.bravehost.com/a.html)

schnitzel_21st
01-11-2004, 10:01 PM
uhhh try getting a status bar script that moves or is updated every few seconds so that the user doesn't have enough time to view the link in the status bar.

Try JavaScriptSource.com (http://javascriptsource.com/)

.::14 YEAR OLD ::.