473,396 Members | 2,093 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

Optimize picture loading

Hi guys,

I created a code where there is a picture in the background (Background.jpg) and once you pass your mouse over some predefined areas of the picture, the specific area changes to another picture (Article1.jpg) and a sound is played. On mouse out, it reverts to the original background
The code below works and the part which is underlined will eventually be copied 4-5 times to create 4-5 of those specific areas.
I have 2 questions:
1. as you will see, I am using Background_Subset1.jpg and Article1.jpg to create the effect. However, Background_Subset1.jpg is only a copy of part of "Backgound.jpg" and could potentially not be used. I assume I will need to create a transparent frame for Article1.jpg to display in onmouseover. Would someone know how to do this?
2. when I access the page, the first time that I hover above the area, the picture and the sound gets downloaded which results in some lag. It works fine afterwards. Is there a way to preload the sounds and images as soon as the page is opened?

Thanks


Expand|Select|Wrap|Line Numbers
  1. <html>
  2. <head> 
  3.  
  4. <script type="text/javascript"> 
  5. function playSound(soundfile) {
  6.     document.getElementById('a1').innerHTML="<embed src='" +soundfile+ "' hidden='true' autostart='true' loop='false' />";
  7. }
  8. </script> 
  9.  
  10. <script type="text/javascript">
  11. function show_confirm(Article1)
  12. {
  13. var r=confirm("Do you want to buy the " + Article1 + " ?");
  14. if (r==true)
  15.   {
  16.   alert("You rock!”);
  17.   }
  18. }
  19. </script>
  20.  
  21.  
  22.  
  23. </head>
  24.  
  25.  
  26. <body>
  27. <div style="position: absolute; left: 220px; top: 300px;">
  28. <img src="Background.jpg"/>
  29. </div>
  30.  
  31. <div style="position: absolute; left: 420px; top: 513px;">
  32. <img src="Background_Subset1.jpg" width="100" height="120" alt="Area1" 
  33. onmouseover="playSound('Sound1.wav'); this.style.cursor='pointer'; this.src='PicOnMouseOver1.jpg';"
  34. onmouseout="this.style.cursor='default';this.src='Background_Subset1.jpg';"
  35. onclick="show_confirm('Article1')"
  36. />
  37. </div>
  38.  
  39. <div> 
  40. <h1 id="a1"></h1> 
  41. </div> 
  42.  
  43.  
  44. <body>
  45. <html>
Jun 25 '11 #1
0 1116

Sign in to post your reply or Sign up for a free account.

Similar topics

3
by: Don | last post by:
Hi, I try to get a simple applet working, the class-file does load, but the image doesn't appear;( An error doesn't appear. The view is and stays 'grey' What I want: Automatic refresh of a...
15
by: Geoff Cox | last post by:
Hello I have following type of code in the header function pre_load_pics() { if (document.images) { var image1 = new Image(400,265); image1.scr = "pic1.jpg";
6
by: John Ortt | last post by:
Hi there everyone, I have a part info form which has a faded image of our company logo as a background. I want to replace the faded image with a bright red warning image on items which have run...
5
by: blk.coffee | last post by:
i have some pictures in a page. there are have difference sizes. some of them are too widen for be arrange in a line. so i been tried to adject their sizes to more suitable. i add a event to...
6
by: Jeff | last post by:
Hey (and thank you for reading my post) In visual web developer 2005 express edition I've created a simple website project.. At this website I want users who register to be able to upload a...
6
by: Ivan Bútora | last post by:
I have recently looked at http://alistapart.com/articles/imagegallery to implement a simple picture gallery on a webpage that I'm working on. Everything works fine; however, I have one question....
1
by: blazingmavrick | last post by:
My problem consits of the following:- i am creating mulitple picturebox's, when the user double clicks on the picture box it opens the opendialog box to load a picture (jpeg only) into the picture...
1
by: Phil Stanton | last post by:
Is there any way of stopping the cursor jumping to a point roughly in the middle of the screen when loading a new picture into an Image Control. The picture is linked and pulled from an external...
5
by: zamuel | last post by:
Hey everyone. I have a strange problem with PHP site. This only happens in IE 6. So, when user logs in there is a placeholder for user's own picture. Also there is a form where this picture can...
3
by: Salim Zaabi | last post by:
Hi EveryBody, Can anyone tell how do I display/show logo or picture when loading a form, NOT ON THE FORM, and it disappears after loading is complete.
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.