JavaScript - Javascript Issue With Google Chrome (position:fixed Horizontal Position:absolute Vert
I'm new to javascript and am not sure why this works in firefox and not chrome.
I am trying to create a script that keeps an object fixed horizontally while bing positioned absolute vertically. if I replace the toPP variable in document.getElementById('fire').style.top = toPP; with say '50px' it will move the element down 50 pxs, but how I have it currently it doesn't do anything in chrome Code: <script type="text/javascript" > window.onscroll = function() { if( window.XMLHttpRequest ) { var x = 0 -document.documentElement.scrollTop; var toP = String(x); var toPP = toP + "px"; document.getElementById('fire').style.position = 'fixed'; document.getElementById('fire').style.top = toPP; } } </script> Similar TutorialsI need to convert a position:fixed element to position:absolute when the user resize their browser window below 1000px. Right now it does nothing. The element always keeps the fixed positioning even after resizing the window. Here's what I have right now: Code: <!DOCTYPE html> <html xmlns="http://www.w3.org/1999/xhtml" lang="en"> <head> <base href="http://www.area51entertainment.co/" /> <title>Emoto <?php echo "$section"; ?></title> <meta charset="UTF-8" /> <meta name="verify-v1" content="" /> <meta name="keywords" content="" /> <meta name="description" content="" /> <meta name="author" content="Andrew McCarrick" /> <meta name="robots" content="index, follow" /> <style type="text/css"> body,html { background: #FFFFFF; /* Old browsers */ color: #000000; font-family: Verdana; margin-right:auto; margin-left:auto; max-width:1000px; padding: 0px; margin-top: 0px; margin-bottom: 0px; } </style> <link rel="stylesheet" href="emoto/style.css" media="screen" /> <link rel="shortcut icon" type="image/x-icon" href="/favicon.ico" /> <link rel="apple-touch-icon" href="http://www.area51entertainment.co/TouchIcon.png" /> <link rel="apple-touch-icon-precomposed" href="http://www.area51entertainment.co/TouchIcon.png" /> <link rel="image_src" href="./logo.png" /> <script language="javascript" src="emoto/float.js"></script> </head> <body> <div class="wrapper"> <div id="header_float"> <div class="header_wrapper"> <div class="logo"> Picture </div> <div class="links"> Home | Settings | Notifications | Requests | Messages | Search Bar </div> <div class="links_right"> Profile Link/Sign-Out </div> </div> </div> <div class="content_wrapper"> Test2Test2 Test2Test2Test2 Test2Test2Test2 Test2Test2Test2 Test2Test2Test2 Test2Test2Test2 Test2Test2Test2 Test2Test2Test2 Test2Test2Test2 Test2Test2Test2 Test2Test2Test2 Test2Test2Test2 Test2Test2Test2 Test2Test2Test2 Test2Test2Test2 Test2Test2Test2 Test2Test2Test2 Test2Test2Test2 Test2Test2Test2 T est2Test2Test2 Test2Test2Test2 Test2Test2Test2 Test2Test2Test2 Test2Test2Test2 Test2 </div> </div> </body> </html> style.css Code: a:link {color: #FFFFFF; text-decoration: none;} a:visited {color: #FFFFFF; text-decoration: none;} a:active {color: #FFFFFF; text-decoration: none;} a:hover {color: #3399FF; text-decoration: none;} .wrapper{ min-height: 2000px; min-width: 1000px; } #header_float{ width: 100%; min-width: 1000px; height: 35px; left:0; right:0; top:0; position: fixed; background: #49963A; z-index: 1000; } .header_wrapper{ width: 1000px; height: 35px; margin-right:auto; margin-left:auto; padding: 0px; margin-top: 0px; margin-bottom: 0px; color: #FFFFFF; } .logo{ float: left; width: 150px; height: 25px; font-size: 26px; position: relative; top: -1px; left: 8px; } .links{ float: left; width: 670px; height: 25px; position: relative; top: 7px; } .links_right{ float: right; width: 180px; height: 25px; position: relative; top: 7px; } .content_wrapper{ position: relative; top: 35px; width: 995px; min-height: 450px; } img{ border: 0px; } float.js Code: if (screen.availWidth<=999) document.getElementById('header_float').style.position = 'absolute'; else document.getElementById('header_float').style.position = 'fixed'; I have created a lightbox for user display on my site. The lightbox is triggered by an onclick link. Works great but I would like to make one switch to it. I would like the lightbox to appear position:fixed; top:10px; onclick. Then if the user scrolls I would like the lightbox to appear position:absolute; top:10px; You can see an example of this here on ESPN's website http://search.espn.go.com/first-take/videos/6. If you click any video it appears position fixed onclick but then position absolute on scroll. This is what I have so far. It shows it all position fixed onclick as I desire, but stays that way on scroll. PHP Code: <a href = "javascript:void(0)" onclick = "document.getElementById('light<?php echo $count;?>').style.display='block'; document.getElementById('light<?php echo $count;?>').style.position = 'fixed'; document.getElementById('light<?php echo $count;?>').style.top = '10px'; document.getElementById('fade<?php echo $count;?>').style.display='block'"> ... [link] ... </a> PHP Code: <div id="light<?php echo $count;?>" class="log-lightbox-content-wrapper"> ... [lightbox content] ... </div> PHP Code: <style> .log-lightbox-content-wrapper {display: none; position:absolute; top: -45px; left: 50%; margin-left: -456px; width: 900px; padding: 16px;background-color: white;z-index:1002; overflow: auto; border-color:#666; border-radius:5px; border-style:solid; border-width:5px; min-height:600px; height: auto !important; height:600px;} </style> Progress: http://instride.info/admin - Click tab that says log - Then click any log post to view light box Hi, Im having a weird issue... I am using position absolute to stick a table header to the top of a div. In the screenshot, under the menu is a div, the buttons and drop downs are at the "top" and grid starts from half way down, now when user scrolls till header is out of view i show the header at the "top" with position absolute. then when user scrolls back down and onto original position the buttons and drop downs are now again at the top exactly at the position where the header was shown, once the header has been shown all the buttons and the drop down are no longer clickable, i.e. there is no reaction, no dropdown shown and no click... whats happening is that IE is thinking that that area at the top where the header was is now invalid, or still occupied by the header or something like that? Its like the buttons and drop downs are kind of "behind" the area where the header was therefore nothing is clickable... And proof of this is that i gave some <BR> spacing to the buttons and drop downs so that they are not at the up most, but halfway down... and things work fine... whats IE up to? or is there some coding i need to do... below is the code for the header to float [it may be coz when the header is not to be shown i set the position to ' ', but i have tried with relative, fixed and static as well to no avail...] Code: <script language="javascript" type="text/javascript"> var floating_header = function() { this.header = document.getElementsByTagName('THEAD')[0].getElementsByTagName('TR')[0]; this.getXY = function(o) { var y = 0; var x = 0; while (o != null) { y += o.offsetTop; x += o.offsetLeft; o = o.offsetParent; } return { "x": x, "y": y }; } this.setheader = function() { if (window.header == undefined) { floating_header(); } var screenpos = this.scrollTop; var theady_max = window.getXY(window.table_obj.getElementsByTagName('THEAD')[0]).y + window.table_obj.offsetHeight; if (screenpos > window.theady - 100 && screenpos < theady_max) { window.header.style.position = 'absolute'; window.header.style.top = this.offsetTop; window.header.style.display = 'block'; window.headerOffsetTop = this.offsetTop; } else { if (screenpos != undefined && window.header != undefined) { window.header.style.position = ''; window.header.style.top = ''; window.headerOffsetTop = undefined; window.header = undefined; } else { if (window.headerOffsetTop) { window.header.style.position = 'absolute'; window.header.style.top = window.headerOffsetTop; window.header.style.display = 'block'; } } } } document.getElementById("divcn").onscroll = this.setheader; this.table_obj = document.getElementsByTagName('THEAD')[0].parentNode; this.theady = this.getXY(this.table_obj.getElementsByTagName('THEAD')[0]).y; }; floating_header(); </script> I'm trying to find a script that will scroll text past fixed position sandbag divs. I want the text to flow around an image as it scrolls. It's easy to do the wrap around the image part. I can't seem to find anything that will continue wrapping the content of your site around the fixed background as you scroll though. Did that make sense? Hello everyone, I just stumbled across this forum and thought maybe someone here could help me with a few coding alterations. I would like to position the rss feed selection fields on this feed output so I can scroll the feed with the selection fields remaining stationary. Code: <link rel="icon" type="image/png" href="rss_include/feed-icon-red.png"> <style language='text/css'> @import url('rss_include/style.css'); </style> <script language="javascript"> var XMLHttpRequestObject = false; var img = new Image(); img.src = "rss_include/loading.gif"; if ( window.XMLHttpRequest ) XMLHttpRequestObject = new XMLHttpRequest(); else if (window.ActiveXObject) XMLHttpRequestObject = new ActiveXObject("Microsoft.XMLHTTP"); function changeOptions() { LoadFeed(); } function LoadFeed(value, initial) { if ( XMLHttpRequestObject ) { var dsource = "rss_include/ajax.php?loadfeed"; if (value) dsource += "=" + value; else { var val = document.getElementById("rss_feed").value; if ( val == "" ) document.getElementById("rss_feed").selectedIndex += 1; dsource += "=" + document.getElementById("rss_feed").value; } dsource += "&fulltext=" + document.getElementById("showtext").checked; dsource += "&showimages=" + document.getElementById("showimages").checked; XMLHttpRequestObject.open("GET",dsource); XMLHttpRequestObject.onreadystatechange = function() { if ( XMLHttpRequestObject.readyState != 4 ) { document.getElementById("rss_div").innerHTML = "<center><img class=\"loading\" src=\"" + img.src + "\"></center>"; } if ( XMLHttpRequestObject.readyState == 4 && XMLHttpRequestObject.status == 200 ) { document.getElementById("rss_div").innerHTML = XMLHttpRequestObject.responseText; } } XMLHttpRequestObject.send(null); } } </script> <?php require_once("rss_include/config.php"); function LoadFile($xml_file) { $xml = null; if ( !file_exists($xml_file) || !($xml = simplexml_load_file($xml_file)) ) { echo '</select>'; echo "Error opening XML feeds file: $xml_file<br>"; return; } return $xml; } function ShowFeedOptions($xml_file) { echo '<select id="rss_feed" onChange="LoadFeed(this.value)" title="GuyWMustang.com RSS Reader">'; $xml = LoadFile($xml_file); if ( $xml == null ) return; $url = array(); foreach($xml->feeds->category as $category) { echo "<option value=\"\">" . $category['name'] . "</option>"; foreach($category->feed as $feed) { if ( $feed['name'] != "" ) { // Add a spacing to the feeds $name = " " . $feed['name']; $url = str_replace("&", "%26", $feed['url']); $url = str_replace("http://", "", htmlspecialchars($url)); echo "<option value=\"$url\">" . $name . "</option>"; } } } echo '</select>'; $options = array(); $rss = $xml->options[0]; if ( strcasecmp($rss['fulltext'],"true") == 0 ) array_push($options, "true"); else array_push($options, "false"); if ( strcasecmp($rss['images'],"true") == 0 ) array_push($options, "true"); else array_push($options, "false"); return $options; } function SetOptions($options) { if ( sizeOf($options) == 2 ) { echo "<script>document.getElementById(\"showtext\").checked = " . $options[0] . ";</script>"; echo "<script>document.getElementById(\"showimages\").checked = " . $options[1] . ";</script>"; } } if ( isset($_GET['links']) ) { $xml = LoadFile($xml_file); if ( $xml == null ) return; // end the link editing return; } ?> <div class="container" id="container_div"> <a name="top"></a> <div class="header_div"> <div style="display:run-in;float:left;"> <font class="graytext">RSS Feed:</font> <?php $options = ShowFeedOptions($feeds_xml); ?> <input type="checkbox" id="showtext" onChange="changeOptions(this)" checked><font class="graytext">Show Full Article Text</font> <input type="checkbox" id="showimages" onChange="changeOptions(this)" checked><font class="graytext">Show Images</font> </div> <?php SetOptions($options); ?> </div> <div class="rss" id="rss_div"> <script>LoadFeed(document.getElementById('rss_feed').value, true);</script> </div> <!-- <p style="padding:0px;margin-right:2px;margin:0px;" align="center"><a class="top" href="#top">Top</a></p> --> </div> <-- CSS BELOW --> Code: body { overflow: auto; font-family: arial; } div.header_div { position: relative; /*background-color: #EFEFEF;*/ width: 100%; overflow: auto; margin: auto; } div.container { /*border: 1px solid black; background-color: #EFEFEF;*/ position: relative; margin: auto; display: block; overflow: auto; /* SPECIFY HEIGHT & WIDTH AS DESIRED */ height: 90%; width: 80%; } div.rss { width: 99%; margin: 2px; background-color: tan; position: relative; /*border: 1px solid black;*/ } img.loading { position: relative; margin-top: 50px; } a.rss_link,a.rss_link:active { display: inline; color: blue; } a.rss_link:hover { color: #BBBBFF; } a.rss_link:visited { color: black; } a.top,a.top:active { text-decoration: none; font-size: 10pt; display: inline; color: black; } a.top:hover { text-decoration: underline; color: brown; display: inline; } font.graytext { font-size: 10pt; color: #444444; } font.rss_title { font-size: 12pt; font-weight: bold; text-decoration: underline; } font.rss_date { font-size: 9pt; font-weight: normal; color: black; display: block; } font.rss_description { font-size: 12pt; color: blue; } select { color: black; font-size: 10pt; background-color: #EAEAEA; } any help would be greatly appreciated.....thanks Hey everyone! I have been fiddling with this for a while now. I cant seem to make anything work. I have tried geocoding services, get position etc. I am sure it can be done so I was hoping someone here may have some experience with the newest API for google maps, V3. In my code below I just have a simple map with a marker.. not important. What I am trying to do is, when you drag the little man to switch the map into streetview, I need to display the current latitude and longitude in some input boxes. This needs to happen in streetview mode though which I have not been able to make happen. Anyone care to lend a few minutes? It must be possible! Code: <html> <head> <meta name="viewport" content="initial-scale=1.0, user-scalable=no" /> <meta http-equiv="content-type" content="text/html; charset=UTF-8"/> <title></title> <style> #map_canvas {height: 500px; width:800px;} </style> <script type="text/javascript" src="http://maps.google.com/maps/api/js?sensor=false"></script> <script type="text/javascript"> function initialize() { var map = new google.maps.Map(document.getElementById("map_canvas"), { mapTypeId: google.maps.MapTypeId.ROADMAP, streetViewControl: true }); var markers = [ { lat: 49.202612, lng: -122.879612, name: 'McDonalds', marker: 'default' }]; // Create the markers for (index in markers) addMarker(markers[index]); function addMarker(data) { var marker = new google.maps.Marker({ position: new google.maps.LatLng(data.lat, data.lng), map: map, title: data.name }); } var bounds = new google.maps.LatLngBounds(); for (index in markers) { var data = markers[index]; bounds.extend(new google.maps.LatLng(data.lat, data.lng)); } map.fitBounds(bounds); } </script> </head> <body onload="initialize()"> <div id="map_canvas"></div> Streetview Latitude: <input type="text" name="latitude" value="?"><br> Streetview Longitude: <input type="text" name="longitude" value="?"> </body> </html> Hello, I have the code below but for some reason it only works when adding the marker to the map (map click). When I drag the marker around, the coordinates and closest address don't update. This code works if I add the marker straight in the initialize() function but not when I add it within the addListenerOnce for map click event. I want to be able to add 1 marker to the map, and update its address and coordinates when dragging the marker around. If someone can help me sort this out... Thanks in advance! Code: <html> <head> <meta name="viewport" content="initial-scale=1.0, user-scalable=no" /> <script type="text/javascript" src="http://maps.google.com/maps/api/js?sensor=false"></script> <script type="text/javascript"> var geocoder = new google.maps.Geocoder(); var marker; function geocodePosition(pos) { geocoder.geocode({ latLng: pos }, function(responses) { if (responses && responses.length > 0) { updateMarkerAddress(responses[0].formatted_address); } else { updateMarkerAddress('No matching address found.'); } }); } function updateMarkerStatus(str) { document.getElementById('markerStatus').innerHTML = str; } function updateMarkerPosition(latLng) { document.getElementById('info').innerHTML = [ latLng.lat(), latLng.lng() ].join(', '); } function updateMarkerAddress(str) { document.getElementById('address').innerHTML = str; } function initialize() { var latLng = new google.maps.LatLng(45.397, 2.644); var map = new google.maps.Map(document.getElementById('mapCanvas'), { zoom: 8, center: latLng, mapTypeId: google.maps.MapTypeId.ROADMAP }); google.maps.event.addListenerOnce(map, 'click', function(event) { var marker = new google.maps.Marker({ position: event.latLng, title: 'Nouveau marqueur', map: map, draggable: true }); // Update current position info. updateMarkerPosition(event.latLng); geocodePosition(event.latLng); }); // Add dragging event listeners. google.maps.event.addListener(marker, 'dragstart', function() { updateMarkerAddress('Dragging...'); }); google.maps.event.addListener(marker, 'drag', function() { updateMarkerStatus('Dragging...'); updateMarkerPosition(marker.getPosition()); }); google.maps.event.addListener(marker, 'dragend', function() { updateMarkerStatus('Drag ended'); geocodePosition(marker.getPosition()); }); } // Onload handler to fire off the app. google.maps.event.addDomListener(window, 'load', initialize); </script> </head> <body> <style> #mapCanvas { width: 500px; height: 400px; float: left; } #infoPanel { float: left; margin-left: 10px; } #infoPanel div { margin-bottom: 5px; } </style> <div id="mapCanvas"></div> <div id="infoPanel"> <b>Marker status:</b> <div id="markerStatus"><i>Click and drag the marker.</i></div> <b>Current position:</b> <div id="info"></div> <b>Closest matching address:</b> <div id="address"></div> </div> </body> </html> downloaded this calendar: http://www.javascriptkit.com/script/...alendar.shtml# works great unless it's in Chrome...then it won't display the correct amount of days in the month (for example, it shows that March has 40 days instead of 31) any ideas? Hi, So here is my problem. I have a main image that has a bunch of images (e.g., stars) on top. I place the stars in absolute positions on top of the main image. If a user resizes the brower, then the position of the main image changes, so then the stars are off position (not on top of the main image). Should I: 1) make the main image be in an absolute position? or 2) do something else such that the main image moves around if the browser is resized? but then I don't know how to re-adjust the positions of the stars on the fly. Anyone have any idea why my position:fixed is being recognized by IE??? It's an embedded link: <font face="gill sans"><a href="#sect1" title="test" style="position:absolute; top:100px; left:40px; text-decoration: none; color: gray; font-size: 15; target="_blank">OUR GOALS</a></font> It works fine in Safari and Firefox... geesh! Hello I am hoping to position some JavaScript on a Web page. Would I use something like this: CSS Code: #diagram { margin-left: 200px; margin-top: 100px; } HTML <script>JavaScript code here</script> <div id="diagram" </div> Thanks for any advice. I'm new to the forum. So hi everyone. The code below works fine on IE and FF but not on Google Chrome. Can someone tell me where I'm doing wrong? Thank you for your answers in advance. Im really looking forward much to hearing from you. You can preview the below code by pasting it to Frontpage, Dreamweaver and etc. Quote: <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>Untitled Document</title> <script type="text/JavaScript"> <!-- function show(id) { if (document.getElementById(id).style.display == 'none') { document.getElementById(id).style.display = ''; } } //--> <!-- function hide(id) { document.getElementById(id).style.display = 'none'; } //--> </script> </head> <body> <div> <div> <table cellspacing="1" cols="3" border="0"> <tbody> <td><a onfocus="hide('tblB');hide('tblC');show('tblA');" href="#">A</a> <td><a onfocus="hide('tblA');hide('tblC');show('tblB');" href="#">B</a> <td><a onfocus="hide('tblB');hide('tblA');show('tblC');" href="#">C</a> </td> </tr> </tbody> </table> </div> <div> <table id="tblA" style="DISPLAY: none" cols="1" cellpadding="2"> <tbody> <tr valign="top" align="left"> <td> You select A, table tblA is shown </td> </tr> </tbody> </table> </div> <div> <table id="tblB" style="DISPLAY: none" cols="1" cellpadding="2"> <tbody> <tr valign="top" align="left"> <td> You select B, table tblB is shown </td> </tr> </tbody> </table> </div> <div> <table id="tblC" style="DISPLAY: none" cols="1" cellpadding="2"> <tbody> <tr valign="top" align="left"> <td> You select C, table tblC is shown </td> </tr> </tbody> </table> </div> </div> </body> </html> How does one get inline styles placed by javascript to work in Google Chrome? Works in Firefox and Opera, I know that Chrome is receiving the correct data by using alerts, but it is not putting the style object in the HTML.
Hi Guys, This is my first post, apologies in advance. I'm new to javascript and working on a form, for some reason the checkboxes work fine in Google Chrome but ar enot working corectly when using IE. Can anyone put me out of my misery? I've attached the code below Thanks in advance Code: //The Javascript // Functional Code - NO NEED to Change function f40_Disable(f40_par,f40_obj,f40_state){ if (f40_par){f40_clds=f40_AllElements(document.getElementById(f40_par)); } else { f40_clds=f40_AllElements(f40_obj.parentNode); } if (!f40_obj.ary){ f40_obj.ary=new Array(); for (f40_0=0;f40_0<f40_clds.length;f40_0++){ if (f40_clds[f40_0].tagName=='INPUT'||f40_clds[f40_0].tagName=='SELECT'||f40_clds[f40_0].tagName=='TEXTAREA'){ f40_obj.ary[f40_obj.ary.length]=f40_clds[f40_0]; } } } for (f40_1=0;f40_1<f40_obj.ary.length;f40_1++){ f40_obj.ary[f40_1].removeAttribute('disabled'); } if (f40_obj.checked==f40_state){ for (f40_2=0;f40_2<f40_obj.ary.length;f40_2++){ f40_obj.ary[f40_2].setAttribute('disabled','disabled'); } } f40_obj.removeAttribute('disabled'); } function f40_AllElements(f40_){ if (f40_.all){ return f40_.all; } return f40_.getElementsByTagName('*'); } Code: <p><LABEL ACCESSKEY=''><input type='checkbox' name='apps' id='apps[0]' value='BW' onclick="f40_Disable(null,this,false);">BW <input type="text" size="15" maxlength="30" disabled="disabled" name="ShipFirst"> <p><LABEL ACCESSKEY=''><input type='checkbox' name='apps' id='apps[1]' value='Advantage' onclick="f40_Disable(null,this,false);">Advantage <input type="text" size="15" maxlength="30" disabled="disabled" name="ShipLast"> <p><LABEL ACCESSKEY=''><input type='checkbox' name='apps' id='apps[2]' value='MS' onclick="f40_Disable(null,this,false);">MS <input type="text" size="15" disabled="disabled" name="ShipEmail"> <p><LABEL ACCESSKEY=''><input type='checkbox' name='apps' id='apps[3]' value='MOC' onclick="f40_Disable(null,this,false);">MOC <input type="text" size="15" maxlength="30" disabled="disabled" name="ShipCompany"> <p><LABEL ACCESSKEY=''><input type='checkbox' name='apps' id='apps[4]' value='Lk' onclick="f40_Disable(null,this,false);">Lk <input type="text" size="15" maxlength="30" disabled="disabled" name="ShipAddress1"> <p><LABEL ACCESSKEY=''><input type='checkbox' name='apps' id='apps[5]' value='CM' onclick="f40_Disable(null,this,false);">CM <input type="text" size="15" maxlength="30" disabled="disabled" name="ShipAddress2"> <p><LABEL ACCESSKEY=''><input type='checkbox' name='apps' id='apps[6]' value='Ga' onclick="f40_Disable(null,this,false);">Ga <input type="text" size="15" maxlength="30" disabled="disabled" name="ShipCity"> <p><LABEL ACCESSKEY=''><input type='checkbox' name='apps' id='apps[7]' value='Ol' onclick="f40_Disable(null,this,false);">Ol <input type="text" size="15" maxlength="30" disabled="disabled" name="ShipZip"> <p><LABEL ACCESSKEY=''><input type='checkbox' name='apps' id='apps[8]' value='Iy' onclick="f40_Disable(null,this,false);">Iy <input type="text" size="15" maxlength="30" disabled="disabled" name="ShipZip1"> <p><LABEL ACCESSKEY=''><input type='checkbox' name='apps' id='apps[9]' value='TPA' onclick="f40_Disable(null,this,false);">TA <input type="text" size="15" maxlength="30" disabled="disabled" name="ShipZip2"> <p><LABEL ACCESSKEY=''><input type='checkbox' name='apps' id='apps[10]' value='CT' onclick="f40_Disable(null,this,false);">CT <input type="text" size="15" maxlength="30" disabled="disabled" name="ShipZip3"> I havent included the whole script as it's quite long, I'm assuming the problem is somewhere within this section. Thanks. A menu is not hovered will be like this: some errors are found 1. Sub-menus are displayed under the menu I want to display All sub-menus on the right and next to menu border Eg: The result I want it to be looked like this: How can I fix the code like that ? 2. Sub menu does have the same size of length. When sub-menu of Pyjamas and Sub-menu of Silk Ties are called, The submenu of Pyjama are longer than the submenu of Silk Ties. How can fix the problem so that All submenu will be the same size of length when they are called ? My code is for leftMenu.php Code: <div id="leftmenu"> <ul> <li><a href="index.php?page=dress">Fashion Dress</a></li> <li><a href="index.php?page=handbag">Hand Bags</a></li> <li><a href="index.php?page=scraves">Scraves</a></li> <li><a href="index.php?page=watch">Bracelet Watches</a></li> <li><a href="#" rel="dropmenu1">Silk Ties</a></li> <li><a href="#" rel="dropmenu2">Pyjamas</a> </li> </ul> </div> <!-- SILK TIES drop down menu --> <div id="dropmenu1" class="dropmenudiv"> <a href="index.php?page=plain">Plain Style</a> <a href="index.php?page=woven">Woven Style</a> </div> <!-- PYJAMAS drop down menu --> <div id="dropmenu2" class="dropmenudiv" style="width: 150px;"> <a href="index.php?page=wonen">For Women</a> <a href="index.php?page=men">For Men</a> </div> <script type="text/javascript"> cssdropdown.startchrome("leftmenu") </script> My code is for leftmenu.css Code: #leftmenu ul{ font-family: Arial, Verdana; font-size: 14px; margin: 0; padding: 0; list-style: none; margin-top: .1em; } ul#leftmenu li { display: block; position: relative; float:left; } #leftmenu li a { display: block; text-decoration: none; background-image:url(images/leftNormal.gif); width: 218px; height: 30px; margin-top: .1em; } #leftmenu li a:hover { display: block; text-decoration: none; background-image:url(images/leftHover.gif); width: 218px; height: 30px; white-space: 1em; color:#FFF; } /* ######### Style for Drop Down Menu ######### */ .dropmenudiv{ position:absolute; top: 0; border: 1px solid #BBB; /*THEME CHANGE HERE*/ border-bottom-width: 0; font:normal 12px Verdana; line-height:18px; z-index:100; background-color: white; width: 200px; visibility: hidden; } .dropmenudiv a{ width: auto; display: block; text-indent: 3px; background-image:url(images/leftmenu.gif); padding: 2px 0; text-decoration: none; font-weight: bold; color: black; } * html .dropmenudiv a{ /*IE only @hắc*/ width: 100%; } .dropmenudiv a:hover{ /*THEME CHANGE HERE*/ background-image:url(images/lefthover.gif); width: auto; display: block; text-indent: 3px; padding: 2px 0; text-decoration: none; font-weight: bold; color:#FFF; } Javascript code in the page of leftmenu.js Code: var cssdropdown={ disappeardelay: 250, //set delay in miliseconds before menu disappears onmouseout //dropdownindicator: '<img src="" border="0" />', //specify full HTML to add to end of each menu item with a drop down menu enablereveal: [true, 8], //enable swipe effect? [true/false, steps (Number of animation steps. Integer between 1-20. Smaller=faster)] enableiframeshim: 1, //enable "iframe shim" in IE5.5 to IE7? (1=yes, 0=no) //No need to edit beyond here//////////////////////// dropmenuobj: null, asscmenuitem: null, domsupport: document.all || document.getElementById, standardbody: null, iframeshimadded: false, revealtimers: {}, getposOffset:function(what, offsettype){ var totaloffset=(offsettype=="left")? what.offsetLeft : what.offsetTop; var parentEl=what.offsetParent; while (parentEl!=null){ totaloffset=(offsettype=="left")? totaloffset+parentEl.offsetLeft : totaloffset+parentEl.offsetTop; parentEl=parentEl.offsetParent; } return totaloffset; }, css:function(el, targetclass, action){ var needle=new RegExp("(^|\\s+)"+targetclass+"($|\\s+)", "ig") if (action=="check") return needle.test(el.className) else if (action=="remove") el.className=el.className.replace(needle, "") else if (action=="add" && !needle.test(el.className)) el.className+=" "+targetclass }, showmenu:function(dropmenu, e){ if (this.enablereveal[0]){ if (!dropmenu._trueheight || dropmenu._trueheight<10) dropmenu._trueheight=dropmenu.offsetHeight clearTimeout(this.revealtimers[dropmenu.id]) dropmenu.style.height=dropmenu._curheight=0 dropmenu.style.overflow="hidden" dropmenu.style.visibility="visible" this.revealtimers[dropmenu.id]=setInterval(function(){cssdropdown.revealmenu(dropmenu)}, 10) } else{ dropmenu.style.visibility="visible" } this.css(this.asscmenuitem, "selected", "add") }, revealmenu:function(dropmenu, dir){ var curH=dropmenu._curheight, maxH=dropmenu._trueheight, steps=this.enablereveal[1] if (curH<maxH){ var newH=Math.min(curH, maxH) dropmenu.style.height=newH+"px" dropmenu._curheight= newH + Math.round((maxH-newH)/steps) + 1 } else{ //if done revealing menu dropmenu.style.height="auto" dropmenu.style.overflow="hidden" clearInterval(this.revealtimers[dropmenu.id]) } }, clearbrowseredge:function(obj, whichedge){ var edgeoffset=0 if (whichedge=="rightedge"){ var windowedge=document.all && !window.opera? this.standardbody.scrollLeft+this.standardbody.clientWidth-15 : window.pageXOffset+window.innerWidth-15 var dropmenuW=this.dropmenuobj.offsetWidth if (windowedge-this.dropmenuobj.x < dropmenuW) //move menu to the left? edgeoffset=dropmenuW-obj.offsetWidth } else{ var topedge=document.all && !window.opera? this.standardbody.scrollTop : window.pageYOffset var windowedge=document.all && !window.opera? this.standardbody.scrollTop+this.standardbody.clientHeight-15 : window.pageYOffset+window.innerHeight-18 var dropmenuH=this.dropmenuobj._trueheight if (windowedge-this.dropmenuobj.y < dropmenuH){ //move up? edgeoffset=dropmenuH+obj.offsetHeight if ((this.dropmenuobj.y-topedge)<dropmenuH) //up no good either? edgeoffset=this.dropmenuobj.y+obj.offsetHeight-topedge } } return edgeoffset }, dropit:function(obj, e, dropmenuID){ if (this.dropmenuobj!=null) //hide previous menu this.hidemenu() //hide menu this.clearhidemenu() this.dropmenuobj=document.getElementById(dropmenuID) //reference drop down menu this.asscmenuitem=obj //reference associated menu item this.showmenu(this.dropmenuobj, e) this.dropmenuobj.x=this.getposOffset(obj, "left") this.dropmenuobj.y=this.getposOffset(obj, "top") this.dropmenuobj.style.left=this.dropmenuobj.x-this.clearbrowseredge(obj, "rightedge")+"px" this.dropmenuobj.style.top=this.dropmenuobj.y-this.clearbrowseredge(obj, "bottomedge")+obj.offsetHeight+1+"px" this.positionshim() //call iframe shim function }, positionshim:function(){ //display iframe shim function if (this.iframeshimadded){ if (this.dropmenuobj.style.visibility=="visible"){ this.shimobject.style.width=this.dropmenuobj.offsetWidth+"px" this.shimobject.style.height=this.dropmenuobj._trueheight+"px" this.shimobject.style.left=parseInt(this.dropmenuobj.style.left)+"px" this.shimobject.style.top=parseInt(this.dropmenuobj.style.top)+"px" this.shimobject.style.display="block" } } }, hideshim:function(){ if (this.iframeshimadded) this.shimobject.style.display='none' }, isContained:function(m, e){ var e=window.event || e var c=e.relatedTarget || ((e.type=="mouseover")? e.fromElement : e.toElement) while (c && c!=m)try {c=c.parentNode} catch(e){c=m} if (c==m) return true else return false }, dynamichide:function(m, e){ if (!this.isContained(m, e)){ this.delayhidemenu() } }, delayhidemenu:function(){ this.delayhide=setTimeout("cssdropdown.hidemenu()", this.disappeardelay) //hide menu }, hidemenu:function(){ this.css(this.asscmenuitem, "selected", "remove") this.dropmenuobj.style.visibility='hidden' this.dropmenuobj.style.left=this.dropmenuobj.style.top="-1000px" this.hideshim() }, clearhidemenu:function(){ if (this.delayhide!="undefined") clearTimeout(this.delayhide) }, addEvent:function(target, functionref, tasktype){ if (target.addEventListener) target.addEventListener(tasktype, functionref, false); else if (target.attachEvent) target.attachEvent('on'+tasktype, function(){return functionref.call(target, window.event)}); }, startchrome:function(){ if (!this.domsupport) return this.standardbody=(document.compatMode=="CSS1Compat")? document.documentElement : document.body for (var ids=0; ids<arguments.length; ids++){ var menuitems=document.getElementById(arguments[ids]).getElementsByTagName("a") for (var i=0; i<menuitems.length; i++){ if (menuitems[i].getAttribute("rel")){ var relvalue=menuitems[i].getAttribute("rel") var asscdropdownmenu=document.getElementById(relvalue) this.addEvent(asscdropdownmenu, function(){cssdropdown.clearhidemenu()}, "mouseover") this.addEvent(asscdropdownmenu, function(e){cssdropdown.dynamichide(this, e)}, "mouseout") this.addEvent(asscdropdownmenu, function(){cssdropdown.delayhidemenu()}, "click") try{ menuitems[i].innerHTML=menuitems[i].innerHTML+" " }catch(e){} this.addEvent(menuitems[i], function(e){ //show drop down menu when main menu items are mouse over-ed if (!cssdropdown.isContained(this, e)){ var evtobj=window.event || e cssdropdown.dropit(this, evtobj, this.getAttribute("rel")) } }, "mouseover") this.addEvent(menuitems[i], function(e){cssdropdown.dynamichide(this, e)}, "mouseout") //hide drop down menu when main menu items are mouse out this.addEvent(menuitems[i], function(){cssdropdown.delayhidemenu()}, "click") //hide drop down menu when main menu items are clicked on } } //end inner for } //end outer for if (this.enableiframeshim && document.all && !window.XDomainRequest && !this.iframeshimadded){ //enable iframe shim in IE5.5 thru IE7? document.write('<IFRAME id="iframeshim" src="about:blank" frameBorder="0" scrolling="no" style="left:0; top:0; position:absolute; display:none;z-index:90; background: transparent;"></IFRAME>') this.shimobject=document.getElementById("iframeshim") //reference iframe object this.shimobject.style.filter='progid:DXImageTransform.Microsoft.Alpha(style=0,opacity=0)' this.iframeshimadded=true } } //end startchrome } I am very appreciated if you help me figure out where I am wrong and let me know how I can fix them clearly. Thanks Hi I got this code for my coutdown: Code: <script language="JavaScript"> TargetDate = "12/31/2020 5:00 AM"; BackColor = "palegreen"; ForeColor = "navy"; CountActive = true; CountStepper = -1; LeadingZero = true; DisplayFormat = "%%D%% Days, %%H%% Hours, %%M%% Minutes, %%S%% Seconds."; FinishMessage = "It is finally here!"; </script> <script language="JavaScript" src="http://scripts.hashemian.com/js/countdown.js"></script> But i don't know how to place it where I want on my html page Normaly I use the CSS value position:absolute Hello Everyone, First of all i'd like to thank you for this wonderful forum, you people have helped me.. Now, i'm back here because i have this problem...i have a website built with drupal, www.plus-demo.info/drupal If you see the second menu, when you hover there is a submenu which pops out...what i want for this popup menu is to display in a fixed position...it shouldn't get out of the borders of the website...there is the code which has to do with it... Please help me... function muchomenu_display() { if (hoverParent) { hoverParent.addClass('hovering'); hoverBin = hoverParent.find('.muchomenu-bin'); /* display position */ //hoverBin.css('top', 'auto'); /* display position end */ animateIn(hoverBin); } } function muchomenu_close(){ if (hoverParent) { oldParentIdx = $('.muchomenu-parent').index(hoverParent); } for ( var i=0 ; i < megaParents.length ; i++ ) { megaParents.eq(i).removeClass('hovering'); } animateOut(hoverBin); } function checkHorizontalPosition(item) { var parentOffset = item.parents('.muchomenu-parent').offset(); var screenWidth = $(document).width(); var itemPosition = item.position(); var padding = 30; var p = item.width() + itemPosition.left + parentOffset.left + padding; if (p > screenWidth) { var newOffset = screenWidth - p; item.css('left', newOffset + 'px'); } } Hello, I am new to JavaScript. I have stuck up at a point. I have generated a table of given dimensions (say 5x5) using JavaScript. Using Mouse events, I want to add a functionality which would display the position of the cell in that table whenever mouse pointer hovers over a particular cell. Here's what I have done. Code: <html> <body> <h1 align="center"><u>ITA Tutorial</u></h1> <h3>Problem Statement</h3> <p>Prepare the table of 5 X 5. On the cursor movement over the table, display the table cell no with row X column value.</p> <br><br> <table border="1" align="center" cellpadding="2"> <script type="text/JavaScript"> var i, j for (i=1;i<6;i++) { document.write("<TR>") for(j=1;j<6;j++) document.write("<TD> </TD>") document.write("</TR>") } </script> </table> </body> </html> I tried adding onMouseover event in the <TD> tag but somehow the whole table disappears when I do that. Please help. So I've now made the layout of my website and I need to know how to position a javascript date I made, in a html table. This is the basic "var d=new date();" code I'm trying to implement in the menu section of my website. Also, I need to know how to do this using an external javascript file.
so basically I have a div that contains the image of a circle and I need to check if the mouse is touching the circle. what approach should I take to this? I need to call another function when the mouse leaves the circle (which will be a square speaking physically) I would assume it has to do with radius, but I am not really sure how to do this with a circle shape. thanks a ton! |