have an image change after mouse over, not working properly - html

When I run it locally, it works fine! But it isn't working when I upload it to my host and try it out online.
here's the code I'm using:
<div class="group">
<div class="left">
<img src="img/up.png" onmouseover="this.src='img/upscroll.png'" onmouseout="this.src='img/up.png'"alt="" />
</div>
<div class="middle">
<img src="img/hobo.png" onmouseover="this.src='img/hoboscroll.png'" onmouseout="this.src='img/hobo.png'"alt="" />
</div>
<div class="right">
<img src="img/blamealcohol.png" onmouseover="this.src='img/blamealcoholscroll.png'" onmouseout="this.src='img/blamealcohol.png'"alt="" />
</div>

Ok, editing answer with a different solution altogether.
Maybe this would do what you are looking for but be a little more simple than the mouseover events.
Here's the demo http://jsfiddle.net/xxhpxd98/
<img class="clock" src="http://images.cdbaby.name/6/0/60x60music2_small.jpg" height="60px" width="60px">
<img class="briefcase" src="http://www.globetrotter1897.com/wp-content/uploads/2013/06/Burgundy-Flight-Bag-and-Small-Brief-60x60.jpg">
.clock {
position:absolute;
z-index:2;
}
.clock:hover {
opacity:0
}
.briefcase {
position:absolute;
}

If the path of the hover image is correct then the problem is something else.
Usually when a page is loaded it loads everything which is present in it in the first view. i.e it will not load any images which is put in the javascript events such as onmouseover. And the mouseover image starts loading only when you do the action (i.e mouseover). And sometime it may fail if the hover image is not cached or if the image couldn't be fetched from server.
There are different ways to solve this problem.
Here are two:
1) First method:You should preload the hover image using javascript
var image1=new Image();
image1.src="img/upscroll.png";
by this method the image upscroll.png will get cached and thus your code works fine.
2) Second method:Include all the hover images in the page and set its width and height to 1 px so that no one will see it but the image will be preloaded. If required you can change the position of these dots to fixed and keep it out of the screen at left:-10px or something like that.
This not only makes the code work fine but also it will avoid the weird appearance of the image getting loaded while mouse is over as it is already cached.

Related

My image is not displayed and the alternative is displayed

I am trying to build a portfolio website, with a moving gallery but the image is not displayed, it shows the alternative image instead. Any help is appreciated.Here is the code:
<div class="section1">
<img class="imgr"src="photo_1.jpg" alt="nothing">
</div>
I even copied the relative path from Vscode, but it is still not working.
It must be the path to the image. Try replacing "photo_1.jpg" with "./photo_1.jpg".

Dreamweaver image map in unordered list

I'm using Dreamweaver to derive the pixel co-ordinates for image maps. One is already done but the other is proving impossible, perhaps because what I intend isn't permissible. My 'impossible' image that I'd like to set hotspots for is one of the list entries inside an unordered list, and whenever I try to select the img element in code view to marquee the map, it won't work and selects the ul element instead.
I only ever use this software for image-mapping and its code validation feature, but its a pain and I'd just as soon do without it if there's a method for defining/calculating pixel co-ordinates for a circular image map.
Any advice, or is DW behaving itself and what I'm trying isn't permitted in HTML?
Updated: To be more specific, it's not just a list but a div-bounded list that acts as a gallery with its input from clickable thumbnail image anchors, as per the code below (just one list item for clarity). What I'd like to do is make 'stuff-medium.jpg' a clickable image that maps to the next image in the gallery (via a href "#two"), providing navigation bars for my gallery also...
<div id="gallery">
<ul id="gallery-interior">
<li id="one"><img src="../images/stuff_medium.jpg"></li>
</ul>
</div>
<div>
<img src="../images/stuff_thumb.jpg">
</div>
Update II -- this code works; I did it by hand, but I'm blown if I can figure out how to do it in DW:
<li id="one"><img src="../images/stuff_medium.jpg" border=0 usemap="#gallerymap">
<map name="gallerymap"><area shape="circ" coords="399,157,30" href="#two" target="_top"></li>
Place a warning in your code that only shows up if javascript is turned off. Use js to add a class to the body. if js is turned off, the class won't be added and the message will be displayed, if js is on, the class will be added to body and the msg will not be displayed
html:
<aside id="js-warning">This site requires JavaScript to work properly. Please turn it on for more awesomeness!
</aside>
js:
<script>
$(document).ready(function(jswarning) {
$('body').addClass('js');
});
</script>
css:
#js-warning {
display:block;
}
.js #js-warning {
display: none;
}

Images only display on initial loading of ASP.MVC page

In the _Layout.cshtml, I have a heading image and two link images that change into other images when the cursor hovers over them. When the page is loaded initially (e.g. //localhost:58055/), the images are shown. When I redirect through the links so that the URL is //localhost:58055/Home/Index, for instance, the images only show the little "broken image" icon. Why might this be? Here is where I specify the header's image in _Layout.cshtml.
<header>
<div class="trippy-title">
<img src="images/title_wider.jpg" width="100%" height="100%" repeat>
</div>
</header>
I recommend you read this article for a better understanding of locations in ASP.net.
http://www.west-wind.com/weblog/posts/2009/Dec/21/Making-Sense-of-ASPNET-Paths
as a simple solution you can use ~/images/title_wider.jpg this works with Razor 2+

preload large gallery/slider images in HTML

I have large, wide images within a portfolio page. The images are saved "progressive" and they load fine.
I was wondering if there's a way though to kind of preload those images to make them appearing faster and smoother. Or maybe there's a way to preload all the other pages and images into the cache so that at least all the following pages after the first appear smooth and fast? Whatever helps to make the pages load faster and smoother.
Any suggestions?
Each image consists of a variety of images, all of them within one wide image (prepared in PSD) and the visitor can shift left and right to call for the respective image to appear in the center.
Unfortunately sacrificing on the image quality or make them smaller is not an option here.
I know there are posts here on preloading images ad stuff but I can't find any that work with the image embedded in the HTML code.
Please have merci, I'm a CSS and Javascript novice, so the simpler the more likely I'll understand it. I'm afraid breaking up the images in single instances (make it a row of images instead of one whole image), place them in a floated div and change the respective Javascript code could be too challenging for me, right...? How else could I do that?
Appreciated!
Here's what I have (I guess it would be overkill to post all my HTML, Javascript and CSS here, I'll post some). The large images are placed within the HTML page and called via Javascript.
see here
<div class="ShiftGroup">
<div class="ShiftGroupC">
<div class="ShiftGroupI"><div id="ShiftGalleryFive"><img src="images/gallery_anzic1.png" width="3348" height="372" alt="imagegallery1" /></div></div>
<div class="ShiftGroupP" style="margin-left: -990px;"><div id="ShiftLeft" class="ShiftGroupD"><span class="pointer"><img src="images/arrowleft.png" width="78" height="50" alt="arrowsleft" /></span></div></div>
<div class="ShiftGroupP" style="margin-left: 341px;"><div id="ShiftRight" class="ShiftGroupD"><span class="pointer"><img src="images/arrowright.png" width="78" height="50" alt="arrowright" /></span></div></div>
and
gallery = document.getElementById('ShiftGalleryFour').style;
This is how we preloaded images in one of our projects:
preloadImages = function(imageIndex) {
// Finds div element containing index (1..n) and url of image
// (both stored as data attributes)
var image = $(".data .image[data-index=" + imageIndex + "]");
// Creates an image (just virtually) that is not embedded to HTML.
// Its source is the url of the image that is to be preloaded
var preloadedImage = $(new Image()).attr("src", image.attr("data-full-url"));
// Bind an event to the "virtual" image to start preloading next image when
// this one is done
preloadedImage.load(function() {
// Start preloading the next one
preloadImages(imageIndex + 1);
});
}
// Start preloading the first image
preloadImages(1)
In your case this solves only one part of the problem - preloading.
I see you include all images in html as img tags. If you want to achieve better performance, do not place any img tags in your html of the gallery. Just div tags that will become the future containers of your images. These divs may have indexes and contain data attributes with image urls (as seen in my example). When your page gets loaded, start preloading procedure. When an "virtual image" gets loaded. Create new image tag inside its container and start preloading the next image.
This will definitely cut off the download time of your page.
My example uses jQuery which simplifies the script. Pure javascript would be more complicated.
UPDATE:
This is how preloading example may work like.
HTML
Let's say you have 4 images and all of them has its container - a div in which individual image is to be placed.
<div class="images">
<div class="image" data-index="1" data-src="image_1_source_path"></div>
<div class="image" data-index="2" data-src="image_2_source_path"></div>
<div class="image" data-index="3" data-src="image_3_source_path"></div>
<div class="image" data-index="4" data-src="image_4_source_path"></div>
</div>
JavaScript
After the the document is loaded, preloading procedure may start. You start by preloading the first image. After this one is loaded, you append it to its container and trigger preloading of the next image. There is also return called if all images are loaded and no container is found.
preloadImages = function(imageIndex) {
var imageContainer = $(".images .image[data-index=" + imageIndex + "]");
return if imageContainer.length === 0
var preloadedImage = $(new Image()).attr("src", image.attr("data-full-url"));
preloadedImage.load(function() {
imageContainer.append(preloadedImage);
preloadImages(imageIndex + 1);
});
}
$(document).ready(function(){
preloadImages(1);
});
Hopefully you get the idea.

Image not displaying in jsp

I have my image placed in a folder called images in the netbeans web pages folder and the link to it in my jsp is in a div as shown below:
<div id="image">
<p>
<img src="${pageContext.request.contextPath}/images/vote_image.GIF"
alt="banner"
width=600px
height=300px
/>
</p>
</div><!--end of image div-->
The problem is the image just doesn't load in the browser. What could be the problem? I used the same code in linux and it used to load the image. Could it be a browser problem, I'm using firefox 3.6 which I don't think should have a problem. Please let me know if any one has a clue as to why this is happening. If the problem is my code let me know how to adjust. Thank you
There are no units used in HTML width and height attributes.
<img src="${pageContext.request.contextPath}/images/vote_image.GIF"
alt="banner"
width="600"
height="300"
/>
Without seeing the rendered source of the page, I'd guess that's your problem. If not, try inspecting your image in Firebug and post what its rendered source looks like.
Also, make sure case sensitivity is not in play: gif vs. GIF.