Random Image/link Runs Twice Then Breaks?
Jan 15, 2003
I'm trying to get a simple script to run where it cycles thru a few images with corresponding links and displays them on a page. I get the script to run 2 times then it breaks on the third with a runtime error saying "object expected Line 0". Code:
View 1 Replies
ADVERTISEMENT
Apr 6, 2004
I need a random JS script which stores a hyperlink around a designated image.
Let's say I've got a company website which offers various products, and on the front page I want a random image to appear of one of the products. When they click on that image, they are transfered to the page for that product. This means that the link and image has to correspond.
View 4 Replies
View Related
Jul 23, 2005
I've found a basic script, however I also need to add alt and title
attributes as well, how would I go about doing this? Code:
View 6 Replies
View Related
May 2, 2010
I am trying to put an image on the front page of my website that changes to one of two random images on mouseover. This part was easy, and has been done (I got the code from [URL] But what I am finding difficult is to make each image link to a different page. For example, if the user mouseovers the main image and sees the 'thumbs up' image, then clicks on it, they should be taken to the 'thumbs up' page. And if the user mouseovers the main image and sees the 'thumbs down' image, then clicks on it, they should be taken to the 'thumbs down' page. The site is here: [URL] I think using 2 arrays is the way to go, but am not sure.
View 3 Replies
View Related
Jul 17, 2006
question: if you want a link which simply runs a js function is it acceptable to have no href? the problem with this is the cursor doesnt change when you hover over, but if you put # as the href it jumps to the top of the screen which is sometimes unacceptable. what it the best solution to this? granted you could do event handling behind the scenes and just intercept the clicks and prevent the href from going anywhere, but sometimes you just want to stick an onclick on the anchor tag!
View 5 Replies
View Related
Aug 27, 2005
I change image.style.width inside a image.onload function. And surprisingly, I found that it runs the onload function on the same image again with the new style.width value. Javascript treats this as a new image! This is the same old image.
Is there a way to pervent it from runing onload the second time?
View 2 Replies
View Related
Aug 31, 2011
I'm trying to use Javascript to have an array of images that load randomly AND work in a slideshow manner so change every 3 seconds (in a logical order). The code I have below presents a random image but how do I get them to continue from the random image and change to the next every 3 seconds?
<script language="JavaScript">
images = new Array(3);
images[0] = "<a href = 'photo1.html'><img src='images/photo1.jpg' alt='Photo 1'></a>";
images[1] = "<a href = 'photo2.html'><img src='images/photo2.jpg' alt='Photo 2'></a>";
images[2] = "<a href = 'photo3.html'><img src='images/photo3.jpg' alt='Photo 3'></a>";
[Code]...
View 4 Replies
View Related
Aug 13, 2011
Below is a very simple jquery slideshow script which functions exactly as it should. But, if I link an image in the DIV set (See proposed change section) the slideshow breaks, instead of cycling through each image in turn it keeps trying to cycle the first image over and over. Script linking in header of HTML page:
<script type="text/javascript" src="script/jquery-1.2.6.min.js"></script>
<script type="text/javascript" src="script/slideshowsc.js"></script>
CSS on HTML controlling DIV position/opacity
#slideshow {
position:relative;
height:186px;
}
#slideshow IMG {
position:absolute;
top:0;
left:20px;
z-index:8;
opacity:0.0;
}
#slideshow IMG.active {
z-index:10;
opacity:1.0;
}
#slideshow IMG.last-active {
z-index:9;
}
DIV setup in HTML page
<div id="slideshow" style="padding-top:15px; text-align:center; width:540px; padding-bottom:43px;">
<img src="images/did-u-know1.png" width="499" height="186" border="0" class="active" />
<img src="images/did-u-know2.png" width="499" height="186" />
<img src="images/did-u-know3.png" width="499" height="186" />
</div>
Proposed Changi in DIV Code here
<div id="slideshow" style="padding-top:15px; text-align:center; width:540px; padding-bottom:43px;">
<a href="whatever.html><img src="images/did-u-know1.png" width="499" height="186" border="0" class="active" border="0" /></a>
<img src="images/did-u-know2.png" width="499" height="186" />
<img src="images/did-u-know3.png" width="499" height="186" />
</div>
Finally, Javascript / Jquery fired through body tag onload
function slideSwitch() {
var $active = $('#slideshow IMG.active');
if ( $active.length == 0 ) $active = $('#slideshow IMG:last');
// use this to pull the images in the order they appear in the markup
var $next = $active.next().length ? $active.next()
: $('#slideshow IMG:first');
// uncomment the 3 lines below to pull the images in random order
// var $sibs = $active.siblings();
// var rndNum = Math.floor(Math.random() * $sibs.length );
// var $next = $( $sibs[ rndNum ] );
$active.addClass('last-active');
$next.css({opacity: 0.0})
.addClass('active')
.animate({opacity: 1.0}, 1000, function() {
$active.removeClass('active last-active');
});
}
$(function() {
setInterval( "slideSwitch()", 8000 );
});
View 1 Replies
View Related
Aug 4, 2011
I have an image that I start out with opacity = 0. Then when I rollover the image area the opacity is set to 1 so I can see the image, and when I roll off of the image the opacity is set back to 0:
This works fine. But the image has an image map that defines a small hot spot. When I roll over the hot spot the image hover state is interrupted and the image goes away. Does anyone know how I can keep the image hover state active when rolling over the image hot spot?
View 3 Replies
View Related
Jun 13, 2010
I am working on a website that uses a random header. I have been trying to figure out how to adjust the code so that the header also serves as a clickable link.
Here is the code that I have:
What do I need to add in order for the header to also serve as a link? I am completely new to JavaScript and I don't understand it very well.
View 1 Replies
View Related
Nov 18, 2011
I've been searching for a resolution to this issue for hours trying to customize my page located at [url]
Specifically, I'm trying to figure out why this line of code is not making my images display in the background:
Original plugin script provided here: [url]
<script>
I made adjustments with my image references that are all located in this directory: [url]
Problem: No images load, and I believe I don't fully understand the .appendTo tage.. I don't know if #body is correct. The author of the plugin assumed I understood the relation. Also #homePage may be incorrect as well.
Additionally, I found another plugin that worked for placing an image in the background (not random), and the background image would scale to size, according the users window. I loved that and it worked, just wanted to add random images to the same script.... first things first... I can't even get an image to display at all with the above code.
In case you wanted to know the script I was using to scale the background image, here it is below (although, as you will see in the code for my site - this image feature is disabled as I am trying to make adjustments).
code for image solutions used:
HTML
CSS
If I can get this second code to work with the random image plugin.
View 4 Replies
View Related
Jul 23, 2005
How would I go about this? I found this piece of code, but this only allows
two links. Does anyone know how to expand on this to add 10 or more?
<script type="text/javascript">
var r=Math.random()
if (r>0.5)
{
document.write("<a href='http://www.w3schools.com'>Learn Web
Development!</a>")
}
else
{
document.write("<a href='http://www.refsnesdata.no'>Visit Refsnes
Data!</a>")
}
</script>
View 1 Replies
View Related
Jan 3, 2010
I have a problem with a random link generator within a DIV. When I try it on my desktop it works fine, but does nothing once I upload it to the website.how to explain what happens, but here is it, more or less:The website is this: http:[url]....
Via an Ajax script, http:[url]..... is loaded into DIV "menu". Here's the script:
<script type="text/javascript">
ajaxpage('menu.html', 'menu') //load "menu.html" into "menu" DIV
</script>
Well, there's another load of stuff inside the <head> tag. You may see it from the main page source code.Anyway, if you go to the menu.html, the link generator will work there as it is intended; however, if you try it from the main page, it won't do anything. But people are not suppossed to go to menu.html. They are suppossed to load it from the index.html (I mean, plain http:url....)So, here's the link generator code:
---------------------------------
<script type="text/javascript">
function randomlinks(){[code].....
I believe this could be solved if I could target the generator to the whole window, 'cause maybe it's trying to open the new page inside the DIV. Well, I don't know...
View 1 Replies
View Related
Feb 7, 2010
I recently used a random link generator found at http://javascriptkit.com in my webpage: http://random-casino.com
View 10 Replies
View Related
May 24, 2010
I used the code on this website [URL]... but it doesn't work. I have 167 links and placed the code correctly but nothing. What am I doing wrong?
View 3 Replies
View Related
Feb 16, 2011
Here's what I usually use and have been using for years and it works great, just not for this particular purpose. I don't have a clue when it comes to javascript.
<noscript><img src="no_script_quote.gif" width="406" height="94"/></noscript><script language="javascript">
var delay=6000
var curindex=0
[code]....
But, now I want to be able to set a default picture to be shown first and have the random pics appear next. I also don't want the default pic to show up again in the random array. So basically, every time the page was first visited, or refreshed it would show the default picture then move into the random pics.
View 8 Replies
View Related
Jan 20, 2010
I'm completely new to this and have no knowledge at all when it comes to javascript. Have been using this script on my site for a while. Is there anyway I can add a URL link to the images that are in my selector? When clicked would go to that page on my website.
<script language="JavaScript">
/*
Random image slideshow- By Tyler Clarke (tyler@ihatecoffee.com)
For this script and more, visit http://www.javascriptkit.com
*/
var delay=10000 //set delay in miliseconds
var curindex=0
[Code]...
View 1 Replies
View Related
Jul 23, 2005
I have huge page of links, to whcih I am currently adding. I would
like to add a "random link" button which would parse the current page,
extract all URLs then load a random link.
View 4 Replies
View Related
Jan 14, 2012
I have this code which creates a text that redirects to a random post for a given feed URL (For blogger blogs)
<div id="myLuckyPost">
</div>
<script type="text/javascript">
function showLucky(root){ var feed = root.feed;
var entries = feed.entry || []; var entry = feed.entry[0]; for (var j = 0;
j < entry.link.length; ++j){if (entry.link[j].rel == 'alternate'){
window.location = entry.link[j].href;}}}
function fetchLuck(luck){ script = document.createElement('script');
script.src = '[URL]'; script.type = 'text/javascript';
document.getElementsByTagName('head')[0].appendChild(script);
} function feelingLucky(root){
var feed = root.feed; var total = parseInt(feed.openSearch$totalResults.$t,10);
var luckyNumber = Math.floor(Math.random()*total);luckyNumber++;
a = document.createElement('a'); a.href = '#random';
a.rel = luckyNumber; a.onclick = function(){fetchLuck(this.rel);};
a.innerHTML = 'View Random Post';
document.getElementById('myLuckyPost').appendChild(a); }
</script> <script src="[URL]">
</script>
How to use this generated random link individually as a variable. (Ex. I don't want to create a text that redirect me to the random post, I want to put it in a variable form to use it in another script). Like This:
var randompost = random post url here;
View 3 Replies
View Related
Oct 8, 2011
<html>
<body>
<div id="link">[code].........
I got stuck in getting this to work (show random element of the array as a link with description)
rl.innerHTML='<a href="addr[ri]">addr[ri]</a>';
This is showing addr[ri] on a page and directs to[url]....
View 3 Replies
View Related
Oct 20, 2007
I am using a module called mod_pageear in my joomla based site that displays an image in the page when the trigger is scrolled over. I would like to change the code to access images in a folder on a random basis. The existing section of the code that accesses the single image is as follows: Code:
View 1 Replies
View Related
May 31, 2006
I have a page on which a random image loads. Each image needs an accompanying image map to take you to the appropriate link. How do I make the appropriate image map links load? Here is my code so far, which works fine.
myStrip = new Array("images/hstrip_1.jpg","images/hstrip_2.jpg");
imgCt = myStrip.length;
function chooseStrip() {
if (document.images) {
randomNum = Math.floor((Math.random() * imgCt));
document.strip.src = myStrip[randomNum];
}
}
View 16 Replies
View Related
Jun 17, 2006
I'm hoping that someone can answer what is probably a really simple question. I've got the Random Image Slideshow script from javascript.com and have it placed in my site where I want it. Now how do I get it to read where I've got the images I want displaying? The folder I have is called homeimages with 10 photos currently inside it.
The script is:
View 5 Replies
View Related
Sep 29, 2006
im having a dumbass problem its probably something stupid as it always is with me. Basically ive incorporated a javascript random image background. It works however it occasionally displays a WHITE bg, as if its trying to link to one of the images in the array and its not there. To get what i mean view the link below and click REFRESH until it goes white. Code:
View 10 Replies
View Related
Apr 19, 2009
I have a javascript that displays a random image whenever the page gets loaded but I can't seem to get the image on the right position...
I've got code...
View 5 Replies
View Related
Oct 26, 2009
Code HTML4Strict:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
[code]....
View 6 Replies
View Related