Web Design and Development Forums

need help with JS mouseover/popup

This is a discussion on "need help with JS mouseover/popup" within the JavaScript Forum section. This forum, and the thread "need help with JS mouseover/popup are both part of the Program Your Website category.


Go Back   Webforumz.com > Program Your Website > JavaScript Forum

Welcome to Webforumz.com.
Register Now Register now!

Reply
 
LinkBack Thread Tools Rate Thread
Old May 3rd, 2008, 22:38   #1 (permalink)
New Member
 
Join Date: May 2008
Location: USA
Posts: 6
need help with JS mouseover/popup

I'm working on redesigning our site and I'm having a problem with a JS mouseover/popup. Hopefully someone here can help me. Right now, when you mouse over an ad, you get a larger version of the ad in a popup window that appears to the left. What I need to do is make it popup to the right instead.
You can see the current popup in action here: http://www.stltoday.com/autos
Go to the Featured Autos section.
This is the JS that it's using:
Code: Select all
function showAdLeft(objname) {
  if(document.getElementById) {
    var adobj=document.getElementById('ad'+objname); // the floating ad
    var obj=document.getElementById(objname); // the graphic link
    var objleft=obj.offsetLeft;
    var objtop=obj.offsetTop;
    var objwidth=obj.offsetWidth;
    var objheight=obj.offsetHeight;
    var objxcenter=(objwidth/2)+objleft;
    var objycenter=(objheight/2) +objtop;
    var objybottom=obj.offsetHeight;
    var adobjwidth=adobj.offsetWidth;
    var adobjheight=adobj.offsetHeight;
    var adobjxcenter=adobjwidth/2;
    var adobjycenter=adobjheight/2;
    adobj.style.left=objleft-adobjwidth;
    adobj.style.top=objycenter-adobjycenter;
    adobj.style.visibility="visible"
  }
}
function showAdRight(objname) {
  if(document.getElementById) {
    var adobj=document.getElementById('ad'+objname); // the floating ad
    var obj=document.getElementById(objname); // the graphic link
    var objleft=obj.offsetLeft-150;  //Make adjustment for being in right column
    var objtop=obj.offsetTop;
    var objwidth=obj.offsetWidth;
    var objheight=obj.offsetHeight;
    var objxcenter=(objwidth/2)+objleft;
    var objycenter=(objheight/2) +objtop;
    var objybottom=obj.offsetHeight;
    var adobjwidth=adobj.offsetWidth;
    var adobjheight=adobj.offsetHeight;
    var adobjxcenter=adobjwidth/2;
    var adobjycenter=adobjheight/2;
    adobj.style.left=objleft-adobjwidth;
    adobj.style.top=objycenter-adobjycenter;
    adobj.style.visibility="visible"
  }
}
function hideAd(objname) {
  if(document.getElementById) {
    adobj=document.getElementById('ad' +objname);
    adobj.style.visibility="hidden"
  }
}
// -->
</script>
I'm assuming this should be an easy fix, but I have no idea where to start. Again, if anyone can help, I would greatly appreciate it. Thanks!
Steve
stevemtno is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
Old May 4th, 2008, 03:49   #2 (permalink)
Nerdy Moderator
 
CloudedVision's Avatar
 
Join Date: Feb 2008
Location: In My Own Little World
Age: 14
Posts: 520
Blog Entries: 4
Re: need help with JS mouseover/popup

instead of "myvar.style.left" do "myvar.style.right"
__________________
Take it easy

Other Road Design

WebForumz Moderator: HTML | Javascript | PHP
CloudedVision is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
Old May 4th, 2008, 16:20   #3 (permalink)
New Member
 
Join Date: May 2008
Location: USA
Posts: 6
Re: need help with JS mouseover/popup

Quote:
Originally Posted by CloudedVision View Post
instead of "myvar.style.left" do "myvar.style.right"
Hi CloudedVision,

Tried it (in both instances in the script), but it didn't make any difference. The popup still goes to the left. Do I need to change something else too?

SteveMTNO
stevemtno is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
Old May 4th, 2008, 18:04   #4 (permalink)
Chief Moderator
 
aso186's Avatar
 
Join Date: Oct 2007
Location: UK
Posts: 715
Blog Entries: 2
Send a message via Skype™ to aso186
Re: need help with JS mouseover/popup

Make sure the element is set to position: absolute, otherwise the left and right values are meaningless.
__________________

aso186 is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
Old May 4th, 2008, 21:21   #5 (permalink)
New Member
 
Join Date: May 2008
Location: USA
Posts: 6
Re: need help with JS mouseover/popup

Quote:
Originally Posted by aso186 View Post
Make sure the element is set to position: absolute, otherwise the left and right values are meaningless.
I'm not sure that is the problem. The page works as it is right now. We;re moving that module from the right side of the page to the left side on the redesign, which is why I need to make the popup go right instead of left. It currently works fine as is. I just need to make it go in the opposite direction. Hope that explains what I'm trying to do a little better.. thanks!

SteveMTNO
stevemtno is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
Old May 7th, 2008, 20:47   #6 (permalink)
New Member
 
Join Date: May 2008
Location: USA
Posts: 6
Re: need help with JS mouseover/popup

OK, now that we've "semi-launched" the new site, I can post a URL so you can see the issue I'm having in the full context of the page.

Go to http://www.stltoday.com/autos and check out the Featured Rides module. You'll see 2 rows of 2 ads.

When you mouse over an ad, the popups currently go to the left. What I would to do is have them go to the right instead. More specifically, I'd like them to appear 25px to the right of the ad in the right column. So if you mouse over the ad in either column, it needs to appear 25px to the right of the ad in the right column.

Any help you can provide will be great appreciated... thanks!!

Steve
stevemtno is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
Old May 7th, 2008, 23:06   #7 (permalink)
Nerdy Moderator
 
CloudedVision's Avatar
 
Join Date: Feb 2008
Location: In My Own Little World
Age: 14
Posts: 520
Blog Entries: 4
Re: need help with JS mouseover/popup

change this:

Code: Select all
adobj.style.left=objleft-adobjwidth;
to this

Code: Select all
adobj.style.right=objleft-adobjwidth;
__________________
Take it easy

Other Road Design

WebForumz Moderator: HTML | Javascript | PHP
CloudedVision is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
Old May 7th, 2008, 23:48   #8 (permalink)
New Member
 
Join Date: May 2008
Location: USA
Posts: 6
Re: need help with JS mouseover/popup

Hey CloudedVision,

Thanks for the quick reply. The popups are still going to the left, but they're staying in the same position now at least. I'd still like to get them closer to the Featured Rides module (ideally, no more than 25px from the edge), and they have to go right instead of left (that's the main thing)

Thanks!!

Steve
stevemtno is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
Old May 8th, 2008, 01:37   #9 (permalink)
Nerdy Moderator
 
CloudedVision's Avatar
 
Join Date: Feb 2008
Location: In My Own Little World
Age: 14
Posts: 520
Blog Entries: 4
Re: need help with JS mouseover/popup

Try that, I added position: absolute. (Like aso has been suggesting) That should fix it.

Code: Select all
function showAdLeft(objname) {
  if(document.getElementById) {
    var adobj=document.getElementById('ad'+objname); // the floating ad
    var obj=document.getElementById(objname); // the graphic link
    var objleft=obj.offsetLeft;
    var objtop=obj.offsetTop;
    var objwidth=obj.offsetWidth;
    var objheight=obj.offsetHeight;
    var objxcenter=(objwidth/2)+objleft;
    var objycenter=(objheight/2) +objtop;
    var objybottom=obj.offsetHeight;
    var adobjwidth=adobj.offsetWidth;
    var adobjheight=adobj.offsetHeight;
    var adobjxcenter=adobjwidth/2;
    var adobjycenter=adobjheight/2;
    adobj.style.left=objleft-adobjwidth;
    adobj.style.top=objycenter-adobjycenter;
    adobj.style.visibility="visible"
  }
}
function showAdRight(objname) {
  if(document.getElementById) {
    var adobj=document.getElementById('ad'+objname); // the floating ad
    var obj=document.getElementById(objname); // the graphic link
    var objleft=obj.offsetLeft-150;  //Make adjustment for being in right column
    var objtop=obj.offsetTop;
    var objwidth=obj.offsetWidth;
    var objheight=obj.offsetHeight;
    var objxcenter=(objwidth/2)+objleft;
    var objycenter=(objheight/2) +objtop;
    var objybottom=obj.offsetHeight;
    var adobjwidth=adobj.offsetWidth;
    var adobjheight=adobj.offsetHeight;
    var adobjxcenter=adobjwidth/2;
    var adobjycenter=adobjheight/2;
    adobj.style.position='absolute';
    adobj.style.right=objleft-adobjwidth;
    adobj.style.top=objycenter-adobjycenter;
    adobj.style.visibility="visible"
  }
}
function hideAd(objname) {
  if(document.getElementById) {
    adobj=document.getElementById('ad' +objname);
    adobj.style.visibility="hidden"
  }
}
// -->
</script>
__________________
Take it easy

Other Road Design

WebForumz Moderator: HTML | Javascript | PHP
CloudedVision is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
Old May 8th, 2008, 15:50   #10 (permalink)
New Member
 
Join Date: May 2008
Location: USA
Posts: 6
Re: need help with JS mouseover/popup

Hi CloudedVision,

I changed the code the way you mentioned above, plus added an additonal position: absolute line to the showAdLeft function that you didn't have in your code. Actually, it didn't make any difference with it there as opposed to it not being there (right now, it's there).

Here's a link to the testing page:

http://www.stltoday.com/stltoday/tes...s?OpenDocument

If you get a chance, can you take another look at it? Also, the popups are still going to the left - even with the position: absolute line(s) in there.

Thanks!!!

SteveMTNO
stevemtno is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Similar Threads
Thread Thread Starter Forum Replies Last Post
Mouseover buttons help! JIM_genius5 HTML Forum 4 Jan 24th, 2008 16:30
mouseover - news headlines WDH JavaScript Forum 4 Dec 10th, 2007 05:18
Problem with Mouseover in Flash Movie thomas159 Flash & Multimedia Forum 1 Sep 11th, 2007 16:46
Image Display on Mouseover not Working in IE7 thefmgirl JavaScript Forum 5 Jan 22nd, 2007 09:51
Customised Alert Popup on MouseOver gribble JavaScript Forum 2 Aug 14th, 2005 23:26



Latest Updates

All Points SEO Security Advisory - CHECK YOUR SITE NOW!

Creative Coding :: February 2008

Webforumz is sponsored by: WESH UK Web Hosting
All times are GMT. The time now is 19:15.

Sleep Study Scoring :: Free Bet :: Website Templates :: Online Betting :: Bookmakers :: Funny Quotes :: Internet Recruitment Software :: Microsoft CRM Experts :: Online Casino :: Decorated Christmas Trees :: Midwife Forums :: Football Betting :: Ecommerce Software :: Web Hosting :: Football Stats :: Dry Cleaning Collection :: xtreme wales - extreme clothing :: Apuestas :: Sharepoint Consultants :: Website Optimisation :: Office Clearance London :: Sharepoint Experts :: Sports Betting :: Casino :: Website Templates :: Web Design Development India :: Online Gambling

Powered by: vBulletin Version 3.7, Copyright ©2000 - 2008, Jelsoft Enterprises Limited.
© 2003-2008 Webforumz.com : All Rights Reserved
Search Engine Friendly URLs by vBSEO 3.2.0 RC6


1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59