JavaScript Strobing Rainbow Links

Jul 10, 2003

I had this idea to implement on the Kid's Activities page on the website for work and after hours and hours and hours of laboriously slaving over code (yeah, right... more like an hour, most of which was spent formatting and commenting the code) I just had to share it with people.

Really, it's not that long but it's pretty well documented throughout and adhears to the PHP/PEAR formatting rules so it looks rather spread out. The code itself probably isn't as streamlined as it could be, either... the "?:" operator instead of an IF-THEN statement and the FOR statement instead of WHILE-LOOP help, but there's always extra tweeks that could be made. I wanted to get the idea out there, though.

I've also posted the code on the cyberdevdigest website at cyberdevdigest.com/code/javascript/rainbow_links.html (http://www.cyberdevdigest.com/code/javascript/rainbow_links.html).

-Tim


<script type='text/javascript'>
<!--
// JavaScript code to produce strobing rainbow-colored links
// on mouseovers. Coded by Timothy Boronczyk, © 2003.

// declare list of colors as a global array (goldenrod used
// because yellow was too difficult to against lighter
// backgrounds)
var colors = Array('red', 'orange', 'goldenrod', 'green',
'blue', 'purple');

// declare color pointer (current color in array by position)
var p_color = 0;

function strobe(x)
{
// set pointer to next color (reset pointer to beginning
// if current position is at the end of the list)
p_color = (p_color == 5) ? 0 : p_color + 1;

// set link color
document.links[x].style.color = colors[p_color];

return true; // no errors
}

function rainbow(link, toggle)
{
// determine which link called this function by matching
// the current key of the DOM's link array
for (id = 0; link != document.links[id]; id++);

if (toggle)
{
// identify setInterval function by name cycle and
// repeatedly call change_color passing current link
// array key
cycle = setInterval('strobe(id)', 100);
}
else
{
// terminate cycle calls
clearInterval(cycle);

// reset link color (assuming that green was original
// color)
link.style.color = 'green'
}

return true; // no errors
}
//-->
</script>

call using onmouseover and onmouseout event handlers, such as in this example:

<a href='link.html' onmouseover="rainbow(this, 1);"
onmouseout="rainbow(this, 0);">CLICK HERE</a>

View 3 Replies


ADVERTISEMENT

Rainbow Text

Feb 11, 2006

in the javascript kit page, theres a text effect called rainbow text. when i try it out, it wrks, but how do i change the font and centre it on the page!

View 3 Replies View Related

Extract Links From Javascript (not Using Javascript)?

May 26, 2006

I am looking for a method to extract the links embedded within the
Javascript in a web page: an ActiveX component, or example code in
C++/Pascal/etc. I am looking for a general solution, not one tailored
to a particular page/script.

Hopefully, the problem can be solved without recreating a complete
Javascript interpreter. Any ideas?

View 9 Replies View Related

How Do I Tell Links Apart In JavaScript (the DOM)

Jul 23, 2005

If I'm looping through the links collection in the DOM in JavaScript how
can I tell the difference between an Image type link and a text url?

I've been looking at document.links[i].href and document.links[i],hostname

are there other properties to look at or am I going to have to parse the
link?

View 2 Replies View Related

Javascript Links

Nov 16, 2006

some websites have a list of javascript links, eg:

javascript:Link(8);
javascript:Link(9);
etc

is there a way to get the list of the real links?

View 2 Replies View Related

Javascript And Links

Jul 14, 2006

I'm using the lightbox gallery (http://www.dynamicdrive.com/dynamicindex4/lightbox2/index.htm) script from dynamic drive to sample images for sale on my website.
I need to be able to add a "Click to buy" link in the actual popup image which will divert them to my order system. It has to be done this way so I know which image they have ordered.

I'd like to add the image in the bottom left section where you can put an image description.

View 7 Replies View Related

External Javascript Links

Dec 16, 2004

i understand that it is possible to include external js links by:

<script language='JavaScript' src='../templates/gill.js'></script>

but inside this gill.js javascript itself, is it possible to add yet another external js that is in the same folder by:

<script language='JavaScript' src='../templates/gill.js'></script>

or

<script language='JavaScript' src='bottom.js'></script>

i suppose both should have work correctly but only the first one works but not the way it should. Is my code wrong or how should i correct it?

View 7 Replies View Related

Javascript Functions And Links

Dec 18, 2001

I wrote a funtion for all my <a href=...> tags. If I use the function, it looks like this:
<a href="test.html" onFocus="myfunction()">

What I want is to automatically add myfunction() to all the links on a page. So I don't want to add onFocus=blablabla each time when I link to another page.

View 5 Replies View Related

Unable To Drag Javascript Links

Jul 23, 2005

Although I am able to drag and drop HTML links, I am no longer able to drag
Javascript links.

In the past, I have been able to drag a link from such places as the
TinyURL! link on http://tinyurl.com to my Links Toolbar. Now I can't. When
I try to drag any Javascript link, my cursor does not change the same way it
does for an HTML link. I see a hand icon for both link types. When I try
to drag a Javascript link, it changes from a hand to an arrow as soon as I
pull the cursor away from the link.

Is this problem new to WinXP SP2? Has one of my settings changed? Has
Norton Internet Security become more actively involved?

View 2 Replies View Related

Using Href:javascript And Anchor Links On Same Page

Jul 8, 2003

I'm working on a project where we're using JavaScript to let users swap styles on a page. To accomplish this, I'm calling the script via href="javascript:swapcss()" on the switch styles button.

Some pages on the site have anchor links. On those pages, if someone swaps styles without hitting any of the anchor links, all is well. But if someone hits an anchor link and then hits the swap button (at this point the URL is pageid.html#anchor), the page just reloads to their anhor point without swapping styles.

Does anyone have a workaround handy? I've tried several alternatives I've found online (href="#" onClick="action"; href="javascript void(0)" ). Nothing works for this case yet. Code:

View 3 Replies View Related

Safari - JavaScript Frames/Links Issue

Oct 10, 2006

I have a DHTML Folder Tree, also known as a TreeView. That is, an expandable/collapsible tree of links. In a frame-less layout everything works great. In a frame-based layout, it doesn't work on Safari/Konqueror.

There are two frames: the left frame contains the tree control; when you click on a link in the tree, the right frame is the target for the links in the tree.

The tree mechanism itself works fine. But there is a problem with the links. What happens on Safari/Konqueror with the frame-based layout is the first link works fine, but all links after that do not. That is, the first click loads a picture on the right frame, but when I click on any other links after that, the target frame is not updated.

View 7 Replies View Related

Make Internal Links Scroll Smoothly With JavaScript

Jul 18, 2007

Can any tell me whether you can change the speed of the scroll at all?

View 1 Replies View Related

JQuery :: Buttons As Links - Working In Firefox And Safari - But In IE Links Do Not Work

Apr 30, 2010

I am new to jquery, and love it so far, but I am more of a designer, not a developer. I am learning jquery to enhance my sites, and I am having a problem figuring out buttons.

I have them working in firefox and safari, but in IE links do not work.

Here is the script I have, and the button code.

View 1 Replies View Related

JQuery :: Menu Navigation - Submenu Links Have A Rounded Box Appear Under Them Instead Of Being Underlined Links

Aug 26, 2009

My menu navigation(Home, Hosting Solution, etc..)

1. The submenu links need to be centered in the middle of the div instead of aligned to the left.

2. Can the submenu links have a rounded box appear under them, instead of being underlined links. Like these at the top: [url]

3: The top tab needs to stay gray/active/on when the mouse is moved down to the submenu or when it is the active button.

Here is the link of the site [url]

View 2 Replies View Related

Jquery :: Create Some Links With Window.open Method - When I Alert What Is Being Built, The Links Don't Work?

Mar 10, 2010

I'm using jquery/ajax to create some links with window.open method. Here's the relevant code:

$("#content").empty();
$.ajax({
type: "GET",[code]..........

Basically, when you click a link a function is called with a parameter based on the particular link you run. Then the code runs through an xml file, and if the parent of the nodes I've cyling through has a value equal to the parameter past to the function, that node is used to create a new link with window.open function attached to it.It all works, or seems to, and when I alert what is being built, it looks right to me, yet the links don't work.I've attached a copy of one of the alerts of one of the links as it's built.

View 5 Replies View Related

JQuery :: Text Links Trapped - But Not Image Links

Nov 28, 2010

I have an image wrapped inside a link tag.<a href="somepage.html"><img id="content" src="img/some.gif" /></a>

I want this .click target to be the link: $('a').click(function(e){

Instead, the target returned is the image [HTMLImageElement].

I have tried using closest()and currentTarget:

But they all still return the image, not the link.

View 2 Replies View Related

URL Links From XML?

May 3, 2011

I,m using js to parse an XML file. the values from each node are written into an HTML table. this all works fine. however when I try to read a web address from the XML and use it as the href in my <a> tag the page jumps straight to the URL specified. how can I prevent this happening?

View 1 Replies View Related

Dynamically Writing Html/javascript From A Javascript Function

Jul 23, 2005

I'm working on some code and am running into brick walls. I'm trying
to write out Javascript with Javascript and I've read the clj Meta FAQ
and didn't see the answer, read many similar posts (with no luck
though), and searched through the IRT.ORG Faqs
(www.irt.org/script/script.htm).

The Javascript is designed to open an popup window and then inside that
window call another script which will resize that window. There may be
another way around this but the reason I tried this approach initially
was that I wanted to call the onload handler in the popup window to
resize the image only after the image had completely loaded. I've had
some code in the primary Javascript file (showimage.js) before that
works if the image has been cached but on the first load, it doesn't
resize properly which tells me it is probably because it is trying to
resize the window based on the image size but it isn't completely known
at that point. So I removed that code and tried placing the resizing
code in the second Javascript file (resizewindow.js). BTW I've tried
other code to open a popup image and automatically size it ie Q1443 at
irt.org but that doesn't do exactly what we need.

Even if there is another way to do this with one file, I still want to
figure out why this isn't working in case I run into it in the future.

I thought what I would need to do to use document.writeln to write
Javascript would be to escape any special characters and to break
apart the script tag ie

document.writeln('</SCRIPT>');

would become

document.writeln('</SCR' + 'IPT>');

I have a HTML page and 2 Javascript files. All files are in the same
directory and have permissions set correctly.

Here are the 3 files (keep in mind wordwrap has jacked up the
formatting):

index.html
----------
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>Test</title>
<SCRIPT type="text/javascript" LANGUAGE="JavaScript1.1"
SRC="showimage.js">
</SCRIPT>
</head>

<body>
Click the house<BR>
<A ONCLICK="newWindow1('house1.jpg','Nice House')"><IMG
SRC="house1thumb.jpg"></A>
</body>
</html>


showimage.js
------------
function newWindow1(pic,sitename)
{

picWindow=window.open('','','width=25,height=25,sc rollbars=1,resizable=1');
picWindow.document.writeln('<html> <head>');
picWindow.document.writeln('<SCR' + 'IPT type="text/javascript"
LANGUAGE="JavaScript1.1" SRC="resizewindow.js"></SCR' + 'IPT>');
picWindow.document.writeln('</head>');
picWindow.document.writeln('<body onload="resizewindow();">');
picWindow.document.writeln('<img src=' + pic + '>');
picWindow.document.writeln('</body> </html>');
picWindow.document.close();
}

resizewindow.js
---------------
function resizewindow()
{
// Do resizing here.
// Right now this isn't being executed
alert("resizing window");
}


Can anyone provide some pointers as to why this javascript is failing?
I'm using IE6 on Win2k and when I click on the image to open the popup
window, it does open the window but it is white with no content and the
system immediately goes from about 4% CPU usage to 100% and
consistently stays there until I kill that window with the task
manager.

View 9 Replies View Related

Multiple Links

Dec 22, 2006

I have an idea but don't know if it's possible, from a technical point
of view.
Imagine to have some text.

Example
"John and Mary go to the cinema."

I'd like to have this kind of links.
By selecting "John" I can go to:
Link 1 (eg. page 1)
Link 2 (eg. page 2)
Link ...

By selecting "John and Mery" I can go to:
Link 4 (eg. page 4)
Link 5 (eg. page 5)
Link ...

So, the word John can be included in two links.
The links are multidirected.
Do you know if there is a package useful for this purpose?
On the contrary, do you have some suggestion useful to achieve this goal?
I really don't know how to start.

It could be nice to have this possibility.

Example
"John and Mary go to the cinema."

I could choose:

"[John] and Mary go to the cinema."
and then go to select among the possible "John" links.

or:

"[John and Mary] go to the cinema."
and then go to select among the possible "John and Mary" links.

View 2 Replies View Related

Links To Frame

Jul 20, 2005

I have a javascript menu vertical in a left frame of a website and I want to
have url-links in that menu to show a html-site in the right frame when I
press a sublink All in javascript.....

View 1 Replies View Related

Intranet Links

Jul 20, 2005

I want to place a piece of JavaScript at the top of my page/s that wil
tell all links on that page to open in certain target windows dependin
on the hostname.

Suppose the intranet address is http://intranet
so this means that the hostname is "intranet" right?
If I want all intranet page links to open in the same window but al
other links (ie external internet links) to open in a new windo
(_blank) then would I use something like below? Please correct an
place I've gone wrong:

if(document.links.hostname == "intranet") {
this.target = "_top";
} return true;

But somewhere in there I would also need an "else" statement to tell i
to open all other links in "_blank" target. Can someone please tell m
where that should be added in. I'm fairly new to javascript and am no
exactly sure what order some of this stuff should go in.

View 1 Replies View Related

No Links Opening In New Tab

May 1, 2009

I found a script for drop down menus on the web. I use it on my homepage (www.k66t6-mf.com). The script works fine. However when you click on the links the pages open in a new tab or window. I do not want this. Does anyone know how I can prevent this from happening? (I know there is a lot of code, and I'm sorry about that).

[Code]...

View 2 Replies View Related

Get Links From A Page?

Sep 8, 2009

Im trying to run javascript on a page, that has a regular frame, and get all the links from the frame. However im not very good at javascript which makes this much harder :cool:This is the script im trying to use:

javascript: for(var i=0; i<window.frames.length; i++){for (i=0; i < document.links.length; i++) { alert(document.links[i].href); }};

View 4 Replies View Related

Get All The Links In Website?

Oct 6, 2010

way to get all the links in a web page using javascript?

View 1 Replies View Related

Posting To Links

Nov 12, 2001

How can i repeatedly post to a url in javascript

is it just using the post and get in html but will it send to the url

View 2 Replies View Related

Frames And #top Links

Jan 28, 2003

<META HTTP-EQUIV="refresh" content="1;URL=#top">

What is the correct way to format the URL of this script so that it refreshes a page in a different frame to the #top.

i.e. not the frame that has this script in it.

ESSENTIALLY what I want here is a hyperlink that refreshes a DIFFERENT Frame to the #top. -- possible?

View 7 Replies View Related







Copyrights 2005-15 www.BigResource.com, All rights reserved