www.webdeveloper.com
Results 1 to 4 of 4

Thread: Pop up info box within table problems

  1. #1
    Join Date
    Jun 2010
    Posts
    2

    Unhappy Pop up info box within table problems

    Hey,

    So I'm experimenting with Javascript and I am making a simple site that features a grid of images and when you mouseover (I'll probably change this to mousedown) a pop-up box appears to the right with some info.

    This works fine when not bound within a table, but as soon as the content is in a table it refuses to move to where the link is. At the bottom of the code is an example of it outside of a table which works fine. I just would really like it to work in a table because of the more rigid structure I get from that, the content is always evenly distributed across the page, no big empty spaces. I also am deliberately trying to make the grid work for all different resolutions which is why every width/height is a %, and am hoping it can work this way too. Here's the code:

    Code:
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
    <title>Music</title>
    
    <style type="text/css" media="screen">
    
    body {
    	background: #1b1b1b;
    }
    
    #wrapper {
    	width:100%;	
    	height:1000px;
    }
    
    table#main {
    	width:100%;
    	height:100%;
    	
    }
    
    table#main td {
    	width:16.667%;
    	height:14.29%;	
    }
    
    table#main img {
    	width:90%;
    	color:#333;
    }
    
    #messageBox{
            position: absolute;
    		padding-left:7px;
    		margin-left:1%;
    		width: 217px;
            height:auto;
            z-index: 1;
            display:none;
    		background:url(images/arrow.png) left no-repeat;
    
    }
    #closeButt{
             width: 100%;
    		 padding-right:10px;
             height: 12px;
    		 font-size:10px;
    		 font-family:Calibri, Modern, Blackletter, Minion, Roman;
             z-index: 1;
             left: 0px;
    		 color:#CCC;
             top: 0px;
             background-color: #660000; 
    }
    #contents{
            width: 100%;
    		padding:10px;
    		color:#FFF;
    		background-color: #8d1001;
    		font-family: Georgia, Palatino, Roman, Calibri, serif;
    		font-size:12px;
            height: auto;
            z-index: 2;
    }
    
    
    
    #notable {
    		width:100%;
    		
    }
    
    #dude {
    width:15%;
    color:#333;
    margin:left;
    margin:right;
    }
    
    </style>
    
    <script language="javascript">
    function show(obj,msg){
    messageBox.style.top=obj.offsetTop
    messageBox.style.left=obj.offsetLeft+obj.offsetWidth+5
    contents.innerHTML=msg+"<p>"+obj.href
    messageBox.style.display="block"
    //alert(obj.offsetWidth);
    }
    </script>
    
    </head>
    
    <body>
    <div id="wrapper">
    <a onMouseOver="show(this,'Demon Days')" onMouseOut="messageBox.style.display='none'">HELLO</a>
    <table id="main" cellspacing="10px">
    <tr>
    <td>
    <a onMouseOver="show(this,'Demon Days')"  onmouseout="messageBox.style.display='none'"><img src="images/artwork/demondays.jpg" border="6%" /></a>
    </td>
    <td>
    <a onMouseOver="show(this,'Its Blitz')" onMouseOut="messageBox.style.display='none'"><img src="images/artwork/itsblitz.jpg" border="6%" /></a>
    </td>
    <td>
    <a onMouseOver="show(this,'Mellon Collie and the Infinite Sadness')" onMouseOut="messageBox.style.display='none'"><img src="images/artwork/melloncollie.jpg" border="6%" /></a>
    </td>
    <td>
    <a onMouseOver="show(this,'Kid A')" onMouseOut="messageBox.style.display='none'"><img src="images/artwork/kida.jpg" border="6%" /></a>
    </td>
    <td>
    <a onMouseOver="show(this,'White Blood Cells')" onMouseOut="messageBox.style.display='none'"><img src="images/artwork/whitebloodcells.jpg" border="6%" /></a>
    </td>
    <td>
    <a onMouseOver="show(this,'Ten')" onMouseOut="messageBox.style.display='none'"><img src="images/artwork/ten.jpg" border="6%" /></a>
    </td>
    </tr>
    
    <tr>
    <td>
    <a onMouseOver="show(this,'IV')" onMouseOut="messageBox.style.display='none'">
    <img id="thumb" src="images/artwork/iv.jpg" border="6%" /></a>
    </td>
    <td>
    <img src="images/artwork/renegades.jpg" border="6%" />
    </td>
    <td>
    <img src="images/artwork/foodandliquor.jpg" border="6%" />
    </td>
    <td>
    <img src="images/artwork/showyourbones.jpg" border="6%" />
    </td>
    <td>
    <img src="images/artwork/watchout.jpg" border="6%" />
    </td>
    <td>
    <img src="images/artwork/sgtpeppers.jpg" border="6%" />
    </td>
    </tr>
    
    <tr>
    <td>
    <img id="thumb" src="images/artwork/inrainbows.jpg" border="6%" />
    </td>
    <td>
    <img src="images/artwork/oracularspectacular.jpg" border="6%" />
    </td>
    <td>
    <img src="images/artwork/rushofbloodtothehead.jpg" border="6%" />
    </td>
    <td>
    <img src="images/artwork/thewall.jpg" border="6%" />
    </td>
    <td>
    <img src="images/artwork/housesoftheholy.jpg" border="6%" />
    </td>
    <td>
    <img src="images/artwork/blackstar.jpg" border="6%" />
    </td>
    </tr>
    
    <tr>
    <td>
    <img id="thumb" src="images/artwork/discovery.jpg" border="6%" />
    </td>
    <td>
    <img src="images/artwork/thecool.jpg" border="6%" />
    </td>
    <td>
    <img src="images/artwork/theblueprint.jpg" border="6%" />
    </td>
    <td>
    <img src="images/artwork/blackholesandrevalations.jpg" border="6%" />
    </td>
    <td>
    <img src="images/artwork/endtroducing.jpg" border="6%" />
    </td>
    <td>
    <img src="images/artwork/whitealbum.jpg" border="6%" />
    </td>
    </tr>
    
    <tr>
    <td>
    <img id="thumb" src="images/artwork/fevertotell.jpg" border="6%" />
    </td>
    <td>
    <img src="images/artwork/madvillainy.jpg" border="6%" />
    </td>
    <td>
    <img src="images/artwork/darksideofthemoon.jpg" border="6%" />
    </td>
    <td>
    <img src="images/artwork/psyencefiction.jpg" border="6%" />
    </td>
    <td>
    <img src="images/artwork/manners.jpg" border="6%" />
    </td>
    <td>
    <img src="images/artwork/blackalbum.jpg" border="6%" />
    </td>
    </tr>
    
    <tr>
    <td>
    <img id="thumb" src="images/artwork/alive2007.jpg" border="6%" />
    </td>
    <td>
    <img src="images/artwork/mmfood.jpg" border="6%" />
    </td>
    <td>
    <img src="images/artwork/stadiumarcadium.jpg" border="6%" />
    </td>
    <td>
    <img src="images/artwork/blackonbothsides.jpg" border="6%" />
    </td>
    <td>
    <img src="images/artwork/wolfgangamadeusphoenix.jpg" border="6%" />
    </td>
    <td>
    <img src="images/artwork/parachutes.jpg" border="6%" />
    </td>
    </tr>
    
    <tr>
    <td>
    <img id="thumb" src="images/artwork/funeral.jpg" border="6%" />
    </td>
    <td>
    <img src="images/artwork/xx.jpg" border="6%" />
    </td>
    <td>
    <img src="images/artwork/nevermind.jpg" border="6%" />
    </td>
    <td>
    <img src="images/artwork/vivalavida.jpg" border="6%" />
    </td>
    <td>
    <img src="images/artwork/revolver.jpg" border="6%" />
    </td>
    <td>
    <img src="images/artwork/okcomputer.jpg" border="6%" />
    </td>
    </tr>
    
    <tr>
    <td>
    <img id="thumb" src="images/artwork/darknight.jpg" border="6%" />
    </td>
    <td>
    <img src="images/artwork/plasticbeach.jpg" border="6%" />
    </td>
    
    </tr>
    
    </table>
    
    <a onMouseOver="show(this,'Demon Days')"  onmouseout="messageBox.style.display='none'"><img id="dude" src="images/artwork/demondays.jpg" border="6%" /></a>
    <a onMouseOver="show(this,'Its Blitz')" onMouseOut="messageBox.style.display='none'"><img id="dude" src="images/artwork/itsblitz.jpg" border="6%" /></a>
    <a onMouseOver="show(this,'Mellon Collie and the Infinite Sadness')" onMouseOut="messageBox.style.display='none'"><img id="dude" src="images/artwork/melloncollie.jpg" border="6%" /></a>
    <a onMouseOver="show(this,'Kid A')" onMouseOut="messageBox.style.display='none'"><img id="dude" src="images/artwork/kida.jpg" border="6%" /></a>
    <a onMouseOver="show(this,'White Blood Cells')" onMouseOut="messageBox.style.display='none'"><img id="dude" src="images/artwork/whitebloodcells.jpg" border="6%" /></a>
    <a onMouseOver="show(this,'Ten')" onMouseOut="messageBox.style.display='none'"><img id="dude" src="images/artwork/ten.jpg" border="6%" /></a>
    
    
    </div>
    
    
    <div id="messageBox">
    <div id="closeButt"></div>
    <div id="contents"></div>
    </div>
    </body>
    </html>

  2. #2
    Join Date
    Apr 2003
    Location
    Netherlands
    Posts
    21,654
    Incorrect referencing and dimensions require units
    Code:
    <script type="text/javascript">
    function show(obj,msg){
    var messageBox = document.getElementById('messageBox');
    var contents = document.getElementById('contents');
    messageBox.style.top=obj.offsetTop+'px';
    messageBox.style.left=(obj.offsetLeft+obj.offsetWidth+5)+'px';
    contents.innerHTML=msg+"<p>"+obj.href
    messageBox.style.display="block"
    //alert(obj.offsetWidth);
    }
    </script>
    At least 98% of internet users' DNA is identical to that of chimpanzees

  3. #3
    Join Date
    Jun 2010
    Posts
    2
    Thanks, but it is still behaving exactly the same. Not moving within the table, but working fine outside of it...

    -peter

  4. #4
    Join Date
    Apr 2003
    Location
    Netherlands
    Posts
    21,654
    You need to position the popup at the element's position: http://www.quirksmode.org/js/findpos.html
    At least 98% of internet users' DNA is identical to that of chimpanzees

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center

"

"

X vBulletin 4.2.2 Debug Information

  • Page Generation 0.24575 seconds
  • Memory Usage 2,882KB
  • Queries Executed 13 (?)
More Information
Template Usage (33):
  • (1)SHOWTHREAD
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_global_above_footer
  • (1)ad_global_below_navbar
  • (1)ad_global_header1
  • (1)ad_global_header2
  • (1)ad_navbar_below
  • (1)ad_showthread_firstpost_sig
  • (1)ad_showthread_firstpost_start
  • (1)ad_thread_first_post_content
  • (1)ad_thread_last_post_content
  • (2)bbcode_code
  • (1)footer
  • (1)forumjump
  • (1)forumrules
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (1)headinclude_bottom
  • (4)memberaction_dropdown
  • (1)navbar
  • (4)navbar_link
  • (1)navbar_moderation
  • (1)navbar_noticebit
  • (1)navbar_tabs
  • (2)option
  • (4)postbit
  • (4)postbit_onlinestatus
  • (4)postbit_wrapper
  • (1)spacer_close
  • (1)spacer_open
  • (1)tagbit_wrapper 

Phrase Groups Available (6):
  • global
  • inlinemod
  • postbit
  • posting
  • reputationlevel
  • showthread
Included Files (26):
  • ./showthread.php
  • ./global.php
  • ./includes/class_bootstrap.php
  • ./includes/init.php
  • ./includes/class_core.php
  • ./includes/config.php
  • ./includes/functions.php
  • ./includes/functions_navigation.php
  • ./includes/class_friendly_url.php
  • ./includes/class_hook.php
  • ./includes/class_bootstrap_framework.php
  • ./vb/vb.php
  • ./vb/phrase.php
  • ./includes/functions_facebook.php
  • ./includes/functions_calendar.php
  • ./includes/functions_bigthree.php
  • ./includes/class_postbit.php
  • ./includes/class_bbcode.php
  • ./includes/functions_reputation.php
  • ./includes/functions_notice.php
  • ./packages/vbattach/attach.php
  • ./vb/types.php
  • ./vb/cache.php
  • ./vb/cache/db.php
  • ./vb/cache/observer/db.php
  • ./vb/cache/observer.php 

Hooks Called (70):
  • init_startup
  • friendlyurl_resolve_class
  • init_startup_session_setup_start
  • database_pre_fetch_array
  • database_post_fetch_array
  • init_startup_session_setup_complete
  • global_bootstrap_init_start
  • global_bootstrap_init_complete
  • cache_permissions
  • fetch_threadinfo_query
  • fetch_threadinfo
  • fetch_foruminfo
  • load_show_variables
  • load_forum_show_variables
  • global_state_check
  • global_bootstrap_complete
  • global_start
  • style_fetch
  • global_setup_complete
  • showthread_start
  • showthread_getinfo
  • strip_bbcode
  • friendlyurl_clean_fragment
  • friendlyurl_geturl
  • forumjump
  • cache_templates
  • cache_templates_process
  • template_register_var
  • template_render_output
  • fetch_template_start
  • fetch_template_complete
  • parse_templates
  • fetch_musername
  • notices_check_start
  • notices_noticebit
  • process_templates_complete
  • friendlyurl_redirect_canonical
  • showthread_post_start
  • showthread_query_postids
  • showthread_query
  • bbcode_fetch_tags
  • bbcode_create
  • showthread_postbit_create
  • postbit_factory
  • postbit_display_start
  • postbit_imicons
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • postbit_display_complete
  • memberaction_dropdown
  • tag_fetchbit_complete
  • forumrules
  • navbits
  • navbits_complete
  • build_navigation_data
  • build_navigation_array
  • check_navigation_permission
  • process_navigation_links_start
  • process_navigation_links_complete
  • set_navigation_menu_element
  • build_navigation_menudata
  • build_navigation_listdata
  • build_navigation_list
  • set_navigation_tab_main
  • set_navigation_tab_fallback
  • navigation_tab_complete
  • fb_like_button
  • showthread_complete
  • page_templates