JavaScript - Mouseout Clild Element Problem
I want a mouseout event to trigger only when I leave the parent element not when I mouseover a child element.
I've been using the script from quirksmode but it can be hard to get working. Code: function doSomething(e) { if (!e) var e = window.event; var tg = (window.event) ? e.srcElement : e.target; if (tg.nodeName != 'DIV') return; var reltg = (e.relatedTarget) ? e.relatedTarget : e.toElement; while (reltg != tg && reltg.nodeName != 'BODY') reltg= reltg.parentNode if (reltg== tg) return; // Mouseout took place when mouse actually left layer // Handle event } I have a function that needs to work only when the parent is moused out of. I didn't make this script. It's called by ondblclick="transition(document.getElementById('select1'),0,800,20)" in the html Code: function transition(ele,dirflag) { if((ele.dirflag == dirflag) && ele.intrans) return; // stops function being called multiple times var totDur = arguments[2] || 1000; // third argument, or one seconds var numSteps = arguments[3] || 30; // fourth argument, or thirty steps (video quality, 30fps) var intrval = totDur/numSteps; // renamed so it can't conflict ele.sopac = 0; // we start at 0 ele.shght = 50; // we start at 50px ele.eopac = 1; // we end at 1 ele.ehght = 140; // we end at 140px ele.iopac = (ele.eopac-ele.sopac)/numSteps; // how much to increment opac ele.ihght = (ele.ehght-ele.shght)/numSteps; // how much to increment hght ele.copac = parseFloat(ele.copac,10) || ele.style.opacity || ele.sopac; // a val for current ele.chght = ele.chght || parseInt(ele.style.height,10) || ele.shght; // a val for current ele.dirflag = dirflag; // changed name to dirflag, stored for reference if(ele.intrans) clearInterval(ele.intrans); // clear timeout if already running... if(dirflag) { // 1 or true = increment // alter visibility here to make an invisible item visible before starting ele.style.display='block'; ele.intrans= setInterval(function() { if(ele.copac<ele.eopac ) { // if mods needed ele.copac=parseFloat(ele.copac,10)+parseFloat(ele.iopac,10); // increment if(ele.copac>ele.eopac) ele.copac=ele.eopac; // error correction ele.chght=parseFloat(ele.chght,10)+parseFloat(ele.ihght,10); // increment if(ele.chght>ele.ehght) ele.chght=ele.ehght; // error correction // set styles accordingly ele.style.opacity = ele.copac; ele.style.filter = 'alpha(opacity='+parseInt(ele.copac*100,10)+')'; ele.style.height = ele.chght+'px'; } else { clearInterval(ele.intrans); // we're done -- clear timeout } },intrval); // do it on intrval timeline } else { // 0 or false = decrement ele.intrans= setInterval(function() { if(ele.copac>ele.sopac || ele.chght>ele.shght) { // if mods needed ele.copac=parseFloat(ele.copac,10)-parseFloat(ele.iopac,10); // decrement if(ele.copac<ele.sopac) ele.copac=ele.sopac; // error correction ele.chght=parseFloat(ele.chght,10)-parseFloat(ele.ihght,10); // decrement if(ele.chght<ele.shght) ele.chght=ele.shght; // error correction // set styles accordingly ele.style.opacity = ele.copac; ele.style.MozOpacity = ele.copac; ele.style.KhtmlOpacity = ele.copac; ele.style.filter = 'alpha(opacity='+parseInt(ele.copac*100,10)+')'; ele.style.height = ele.chght+'px'; } else { clearInterval(ele.intrans); // we're done -- clear timeout // and make the item disappear here since it's done transitioning. ele.style.display='none'; } },intrval); // do it on intrval timeline } } // all done! I tried to do this: Code: function transition(ele,dirflag,e){ if (!e) var e = window.event; var tg = (window.event) ? e.srcElement : e.target; if (tg.nodeName != 'DIV') return; var reltg = (e.relatedTarget) ? e.relatedTarget : e.toElement; while (reltg != tg && reltg.nodeName != 'BODY') reltg= reltg.parentNode if (reltg== tg) return; // Mouseout took place when mouse actually left layer // Handle event if((ele.dirflag == dirflag) && ele.intrans) return; // stops function being called multiple times var totDur = arguments[2] || 1000; // third argument, or one seconds var numSteps = arguments[3] || 30; // fourth argument, or thirty steps (video quality, 30fps) var intrval = totDur/numSteps; // renamed so it can't conflict ele.sopac = 0; // we start at 0 ele.shght = 50; // we start at 50px ele.eopac = 1; // we end at 1 ele.ehght = 140; // we end at 140px ele.iopac = (ele.eopac-ele.sopac)/numSteps; // how much to increment ........ With this in the html onmouseout="transition(document.getElementById('select1'),1,800,20,event) but it doesn't work. the event isn't getting passed to the function. i have tried to move the event before document.getElementById and put e before ele in the function but it still doesn't work. Nothing fires at all. I've just added the quirksmode script to other functions in the past and had them work. I know this won't be the last time I need to stop problems with mouseover so can you give me some tips on what is going wrong. and please no script librarys. Similar TutorialsSo after a great deal of work I finally get my code working... Main hurdle was clearing the setTimeOut... A simple example: Code: <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="de-DE"> <head> <script type="text/javascript" src="js1.3.js"></script> <style> .windowcht { position:absolute; top:30%; width:150px; height:150px; right:50%; background:yellow; } </style> <script> $(function() { //mouse hover effects $('.windowcht').fadeTo('slow', 0.1); $('.windowcht').mouseenter(function() { $(this).fadeTo('fast', 1); }); $('.windowcht').mouseleave(function() { var hov = this; var timeout; timeout = setTimeout(function() { $(hov).fadeTo('slow', 0.1); }, 2000); $('.windowcht').mouseenter(function() { clearTimeout(timeout); }); }); }); </script> </head> <body> <div class="windowcht"> This is my text </div> </body> </html> I would love any suggestions for my code to be less resource hungrey, I mean pure js code, not jquery. Suggestion?? The following piece of codes work like this: When mouse pointer is moved over the Button, the text of the button changes; When it is moved out of the button, the background color of the button changes. <html> <head> <script type="text/javascript"> function over(e) { if(e.toElement){ if(e.toElement.tagName.toLowerCase() == "input"){ e.toElement.value="IE New"; } } } function out(event) { if (event.srcElement){ if(event.srcElement.tagName.toLowerCase() == "input"){ event.srcElement.style.background= "green"; } } } </script> </head> <body> <div id="1">aaaaaaaaaaaaaaaaaa </div> <input type="button" value="Button 1" onmouseout="out(event)" onmouseover="over(event)" /> </body> </html> This sequence works fine, until the following case: First let's see the direction of the button: (left) <--------> BUTTON <--------> (right) Now, move the mouse over to the button, from the right side of the button, both the text and the background color of the button are changed. Obviously, the mousemoveout event is also triggered. I believe in this case, only the mousemoveover event should be triggered. What caused this? Thanks Scott Hello, I found the javascript for triggering audio on mouseOver (on the page link below) very helpful. Question is - how to stop the audio on mouseout? http://www.javascriptkit.com/script/....shtml#current I think this is a simple problem, but lets see... As the title suggests, I'm building a menu where when the user clicks on their username, a menu slides down. That part is easy. Using jQuery, I'm using slideToggle so when they click it again it moves back up. But what I'd also like to do is make it so if they leave the menu "area" (eg, are not on the username or the menu) I'd like the menu to slide back up. I tried Code: $('#userLink, #userMenu').mouseout(function () { $('#userMenu').slideUp('fast'); }); But there is the obvious flaw of when they mouse from the username to the menu, they leave the username and the menu closes back up. Anyone have thoughts on how this is/can be done? Is there a way to check what element the mouse is on at any given time? My other thought was to have a function set on timeout that would check if its on one of the accepted elements, and if not, close the menu and disengage the timeout. I have a navigation menu. When you mouseover, there's a sub-menu that appears. It remaining until you mouseout from the submenu or that "top level" item you mousedover in the first place. I want to change the mouseout function so it does nothing until you mousover another top-level item in the navigation. Example Shown he http://www.courage.ca Code: startList = function() { if (document.all&&document.getElementById) { navRoot = document.getElementById("nav"); for (i=0; i<navRoot.childNodes.length; i++) { node = navRoot.childNodes[i]; if (node.nodeName=="LI") { node.onmouseover=function() { this.className+=" over"; } node.onmouseout=function() { this.className=this.className.replace (" over", ""); } } } } } window.onload=startList; Using a css dropdown menu with javascript work-around for ie. Sorry to post yet again on this subject, but I couldn't find a solution in previous threads. My problem (in IE): I'm using the workaround as detailed in the "suckerfish" article http://htmldog.com/articles/suckerfish/dropdowns/ . Works great to drop my menu down, but when I mouse out the menu remains. On checking back with the original article, they have the same problem so I tried adapting the mouseout line in different ways. Still can't figure it out. Here is my site: http://www.centraloregonfoodnetwork.com/indexx.html Drop down menu only exists for the "producers directory". Thanks I pretty sure just looking at this that there must be a simpler way of executing this. I have a number of objects (always varies) coming into the div tag #apply_row and has the class .rotate_color and .highlight Code: <div id="apply_row" class="rotate_color highlight"> milk </div> <div id="apply_row" class="rotate_color highlight"> coffee </div> <div id="apply_row" class="rotate_color highlight"> cheese </div> And I have the javascript written to give a different color for dd and :even and to add a highlight color when user puts the mouse over. Code: $(document).ready(function() { //alternate div colors $("div.rotate_color:odd").css("background-color", "#FFFFFF"); $("div.rotate_color:even").css("background-color", "#F9F5E8"); //highlight and return back to original color on mouseout $("div.highlight").mouseover(function(){ $(this).css("background-color", "#F6E9D0"); $("div.highlight").mouseout(function(){ //clear background color to none $(this).css("background-color", ""); //change back to original $("div.rotate_color:odd").css("background-color", "#FFFFFF"); $("div.rotate_color:even").css("background-color", "#F9F5E8"); }); }); }); This does seem a bit excessive, but it does work except that it is *really slow to make the css changes. I couldn't really get .hover to work either with changing the background back to the original. The way the site is set up right now, it would be best to leave the background-color for these particular ID's and Classes out of the CSS file itelf (blah, too long to explain why). Any suggestions??? Thanks, Daniel This is what my code is supposed to do: 1. create a select list that changes the photo showing, (which I have) 2. create script so that when the user hovers over the image it shows a div 3. when the users mouse is off the image/div shows the coordinates where it last left 4. on mouseout hides the div again (this is the part I'm stuck on) This is my html: Code: <style> #selectdiv { position:absolute; left:10px; top:10px; width:400px; height:400px; } #mylist { position: absolute; left: 200px; top: 100px; width:inherit; height:inherit; } #myyellow { position: absolute; left: 600px; top: 100px; width:300px; height:200px; background-color:#FF3; } </style> <body> <div id="selectdiv"> <h1 style="font-size:28px">Select a Beatle</h1> <select name="beatles" size="1" id="myselect" onchange="showDiv();"> <option value="-">-</option> <option value="J">John</option> <option value="P">Paul</option> <option value="G">George</option> <option value="R">Ringo</option> </select> </div> <div id="mylist" style="display:none" onmouseover="showYellow(event);" onmouseout="showpixels(event)"></div> <div id="John" style="display:none"> <img src="beatles_john.jpg" /> </div> <div id="Paul" style="display:none"> <img src="beatles_paul.jpg" /> </div> <div id="George" style="display:none"> <img src="beatles_george.jpg" /> </div> <div id="Ringo" style="display:none"> <img src="beatles_ringo.jpg" /> </div> <div id="myyellow" style="display:none"></div> <div id="msg"></div> </body> This is my script: Code: function showDiv() { var mySelect = document.getElementById("myselect"); var myList = document.getElementById("mylist"); switch (mySelect.value) { case 'J': myDiv = document.getElementById("John"); myList.innerHTML = myDiv.innerHTML; myList.style.display = "block"; //Makes div viewable break; case 'P': myDiv = document.getElementById("Paul"); myList.innerHTML = myDiv.innerHTML; myList.style.display = "block"; //Makes div viewable break; case 'G': myDiv = document.getElementById("George"); myList.innerHTML = myDiv.innerHTML; myList.style.display = "block"; //Makes div viewable break; case 'R': myDiv = document.getElementById("Ringo"); myList.innerHTML = myDiv.innerHTML; myList.style.display = "block"; //Makes div viewable break; } } function showYellow(event) { var myyellow = document.getElementById("myyellow"); myyellow.style.display = "block"; } function showpixels(event) { x=event.clientX y=event.clientY var myMsg = document.getElementById("msg"); myMsg.innerHTML = "X coords: " + x + ", Y coords: " + y; } Any feed back is greatly appreciated. I have the following HTML code: Quote: <form id="registration" action="/cgi-bin/registration.cgi" method="POST" onsubmit="return control()"> <fieldset> <legend>Fill up this module</legend> Private <input id="private" type="radio" name="type" value="private" onclick="return addPrivate()"/><br/> Community/Organization <input id="organization" type="radio" name="type" onclick="alert('Organization')"/><br/> <br/> and the following javascript code: Quote: function addPrivate() { var root = document.getElementById('registration'); var label1 = document.getElementById('label'); label1.appendChild(document.createTextNode('First Name: ')); var label2 = document.getElementById('label'); label2.appendChild(document.createTextNode('Last Name: ')); var label3 = document.getElementById('label'); label3.appendChild(document.createTextNode('Address*: ')); var label4 = document.getElementById('label'); label4.appendChild(document.createTextNode('Profession: ')); var div = document.createElement('div'); div.appendChild(label1); div.appendChild(label2); div.appendChild(label3); div.appendChild(label4); root.appendChild(div); } but div tag is not added. Where is the problem? Code: function offPar(){ alert(this.offsetParent.id); } function init(){ var mine = document.getElementById("mid"); var other = document.getElementById("inner"); mine.addEventListener("click", offPar, false); other.addEventlistener("click", offPar, false); } window.addEventListener('load', init, false); HTML : <div id = "content"> <div id = "mid"> <div id = "inner"> <p class = "par"> </p> </div> </div> </div> I can add an event listener to the #mid div but I can't to the #inner div. Anyone now why this is? Sorry I can't provide more info. That's all I Know! TTFN John I am trying to make images change as the user selects the option from the dropdown menu , I have called alert("test1"); alert("test2"); to check if the functions are being called but only the first one happens, can you please tell me what's wrong with the script. Here is the script:
Code: var oImageChooser; addEvent( window, "load", initialize) function initialize() { alert("test1"); var oImageChooser = document.getElementById("imageChooser"); addEvent(oImageChooser, "change", loadCached); } var imageLibrary = new Array(); imageLibrary["image1"] = new Image(120,90); imageLibrary["image1"].src = "images/desk1.gif"; imageLibrary["image2"] = new Image(120,90); imageLibrary["image2"].src = "images/desk2.gif"; imageLibrary["image3"] = new Image(120,90); imageLibrary["image3"].src = "images/desk3.gif"; imageLibrary["image4"] = new Image(120,90); imageLibrary["image4"].src = "images/desk4.gif"; function loadCached() { alert("test2"); var imgChoice = oImageChooser.options[oImageChooser.selectedIndex].value; document.getElementById("thumbnail").src = imageLibrary[imgChoice].src; } here is the html Code: <html> <head><title>Image dropdown</title> <script type = "text/javascript" src = "experimento5.js"> </script> </head> <body onload = "initialize()"> <h1> Choose any image</h1> <img id = "thumbnail" src = "images/desk1.gif" > <form> <select id = "imageChooser"> <option value = "image1"> Bands</option> <option value = "image2"> Clips</option> <option value = "image3"> Lamp</option> <option value = "image4"> Erasers</option> </select> </form> </body> </html> Hi, im new to Js and i have this code: Code: var div = document.createElement("div"); div.id = field+count; div.name = field+count; div.class = "bubble_green"; var p = document.createElement("p"); p.appendChild(document.createTextNode('Question '+count)); div.appendChild(p); field_area.appendChild(div); assuming that the variables are all correct and working, why is only this produced: Code: <div id="question_3"><p>Question 3</p></div> instead of: Code: <div id="question_3" name="question_3" class="bubble_green"><p>Question 3</p></div> and is there a solution? Hi guys, I am currently stuck up on something.. check this page http://dev.andrewfopalan.com/new_slider.html Well for starters.. I am trying to mimic this effect.. http://www.vogue.com/ The slider on the very top.. A quick preview of what I did was.. I used this plugin.. easyslider().. And then edited it.. since I am still learning jQuery and javascript.. so I made changes to the controls... usually the elements for design.. all I did was that.. The first problem was how to make it center like the one on the vogue.. so it was done... Second the masking problem.. I had alot of trouble thinking how I am going to do this.. because whenever I used absolute position on masks and the controls, everything is messed up on all browser.. So my problem primarily was how to make the effect like vogue mask, so what I did was used opacity on the list... and add a class active that regains the opacity 1 on the middle part of the slider.. so that was done.. My follow up problem is whenever I am navigating through the slider.. I add the "active" class on the next item on the list.. up until there I am fine.. but when I am at almost at the end, at the 5th slider, I am not getting the active class? and after a couple of clicks on the "next".. it wont navigate through... here's the code for the next button: Code: // this gets the current location of the active slider on the list.. $("a#"+options.nextId).click(function(e){ var id= $('.active').attr('id'); //this removes the "active" class on the slider.. and then goes to the next item on the list.. and then add the class "active" to the next image slide.. $("ul li:nth-child("+(id)+")").removeClass('active').next().addClass('active'); // this is the plugin's animation to move to the next slide.. animate("next",true); Heres' the code for the animate Code: function animate(dir,clicked){ if (clickable){ clickable = false; var ot = t; switch(dir){ case "next": t = (ot>=ts) ? (options.continuous ? t+1 : ts) : t+1; break; case "prev": t = (t<=0) ? (options.continuous ? t-1 : 0) : t-1; break; case "first": t = 0; break; case "last": t = ts; break; default: t = dir; break; }; var diff = Math.abs(ot-t); var speed = diff*options.speed; if(!options.vertical) { p = (t*w*-1); $("ul",obj).animate( { marginLeft: p}, { queue:false, duration:speed, complete:adjust, } ); } else { p = (t*h*-1); $("ul",obj).animate( { marginTop: p }, { queue:false, duration:speed, complete:adjust } ); }; heres the adjust code function Code: function adjust(){ if(t>ts) t=0; if(t<0) t=ts; if(!options.vertical) { $("ul",obj).css("margin-left",(t*w*-1)); } else { $("ul",obj).css("margin-left",(t*h*-1)); } clickable = true; if(options.numeric) setCurrent(t); }; I am very still new to this jQuery thing.. but I am trying my best to learn.. Hope someone could teach me and help me on this... Hello I am fairly new to Javascript. I have a function which takes a string which consists of key value pairs and sets a form control based on key being the form element name and value being the value to set. eg string could be "key1=orange;key2=2;key3=whetever" Here is the function: function processresponse(frm, serverResponse) { var items = serverResponse.split(";"); for(var i = 0; i < items.length; i++) { var item = items[i]; var eqchar = item.search("="); if(eqchar != -1) { var key = item.slice(0, eqchar); var value = item.slice(eqchar+1); var elemname = key; if(document.getElementById(elemname) != null) { var type = frm.elements[elemname].type; if (type=="checkbox") { value == "1" ? frm.elements[elemname].checked=true : frm.elements[elemname].checked=false; } else if (type=="text"){ //do processing for text (text input) frm.elements[elemname].value = value; } else if(type=="select-one"){ //only one is openformmode - default to [0] - true if(value == "0" || value.length == 0) { frm.elements[elemname].options[0].selected = true; } else { frm.elements[elemname].options[1].selected = true; } } else { alert("unknown ctrl type: " + type + " name: " + frm.elements[elemname].name + " val: " + value + " key: " + key); } } //if(frm.getElementById(elemname) } } } The problem line is: var type = frm.elements[elemname].type; elemname is case sensitive so if for example the form element is called dog and the string elemname is Dog, then the line fails with Error: 'elements[...].type' is null or not an object So my check if(document.getElementById(elemname) != null) is insufficient to guard against this. I realise I could do a try catch but there must be a more legant way than that. How can I test the formname more reliably? Any ideas would be very welcome. Angus Code: var bakaBanner; bakaBanner = document.getElementById('head'); if (bakaBanner) { var str=/\/images\/banners\/[A-Za-z0-9_]+.[a-z]+/; document.write(str.replace(/\/images\/banners\/[A-Za-z0-9_]+.[a-z]+/, "http://img218.imageshack.us/img218/5904/revyblacklagoon1.png")); } Alright, here's the deal... This is a script to be used in Greasemonkey. The page this is for changes their banner every 5 minutes, the name changes and it could be either jpg or png. I'm fairly certain my regex itself: \/images\/banners\/[A-Za-z0-9_]+.[a-z]+ Is correct... Here's an example of what it's looking through: Code: <div id="head" style="background-image: url(/images/banners/kiminitodoke.jpg);" > <div id="header_left"> <div id="rss"> My guess is that it has something to do with this line: document.write(str.replace(/\/images\/banners\/[A-Za-z0-9_]+.[a-z]+/, "http://img218.imageshack.us/img218/5904/revyblacklagoon1.png")); I'm new with Javascript, so I don't really understand why it's not working... :/ Hi, I have a small problem with a page I'm working on. I have an anchor tag inside a table that has a mouseover event that updates a contextual help box. I need to add a similar mouseover event to the anchor tag that does the same thing, but updates the help box with different text. The problem I have is that when the mouse is over the table, no matter if I move the mouse over the anchor, the help text only displays the message that is passed from the table's mouseover function call. I think the solution *may* be something to do with event bubbling, but I'm not exactly sure how to implement it. The code I'm dealing with is below: The code below is PHP. The table mouseover (for reference): Code: echo "<table class='cleanTable' width='100%' style='margin-top: 5px'"; echo " onMouseOver=\"updateHelpText('Message 1.');\" onMouseOut='clearHelpText();'>"; echo "<tr><th> </th><th> </th><th>First Name</th><th>Surname</th><th>Last Login</th></tr>"; The anchor mouseover: Code: echo "<tr class='cleanrow'><td><a href='newMember.php'><img border='0' src='images/icon_add.gif'></a></td><td></td>"; echo "<td colspan='3'><a class='workbenchLink' href='newMember.php' onMouseOver=\"updateHelpText('Message 2');\" onMouseOut='clearHelpText();'>Invite a new colleague...</a></td></tr>"; echo "</table>"; The function (javascript): Code: function updateHelpText(newText) { document.getElementById("helpBox").innerHTML = "<h4> " + newText + "</h4>"; } Any help with this would be great, thanks. The bit of code in bold in the code below is giving me this error in IE: Error: Code: Webpage error details User Agent: Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 6.0; Trident/4.0; Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1) ; SLCC1; .NET CLR 2.0.50727; Media Center PC 5.0; .NET CLR 3.5.30729; Tablet PC 2.0; InfoPath.2; OfficeLiveConnector.1.4; .NET CLR 3.0.30729; OfficeLivePatch.1.3; MSN OptimizedIE8;ENGB) Timestamp: Tue, 16 Mar 2010 15:07:11 UTC Message: HTML Parsing Error: Unable to modify the parent container element before the child element is closed (KB927917) Line: 0 Char: 0 Code: 0 URI: http://www.mateinastate.co.uk/users/mateinastate Code: Code: if(document.getElementById('msn1').innerHTML=="") { document.getElementById('msn1').style.display='none'; } if(document.getElementById('yahoo1').innerHTML=="") { document.getElementById('yahoo1').style.display='none'; } if(document.getElementById('skype1').innerHTML=="") { document.getElementById('skype1').style.display='none'; } if(document.getElementById('facebook1').innerHTML.toLowerCase().substr(0,18)=='<a href="http://">') { document.getElementById('facebook1').style.display='none'; } else if(document.getElementById('facebook1').innerHTML.toLowerCase().substr(0,11)=='<a href="">') { document.getElementById('facebook1').style.display='none'; } else { document.getElementById('fbook-add').innerHTML='Facebook Profile'; } What it's saying isn't actually true (I don't think)... this is how the section is laid out: Code: <div id="submenu1" class="anylinkcss"> <ul> <li class="contact-pm"><a href="/index.php?do=pm&act=new&to=$RateViewProfileUserName$&returnurl=$ReturnURL$">PM me</a></li> <li class="contact-email"><a href="/index.php?do=email&id=$RateViewProfileUserId$">E-mail me</a></li> <li class="contact-msn" id="msn1">$RateViewProfileUser-profile_msn$</li> <li class="contact-yahoo" id="yahoo1">$RateViewProfileUser-profile_yahoo$</li> <li class="contact-skype" id="skype1">$RateViewProfileUser-profile_skype$</li> <li class="contact-facebook" id="facebook1"><a href="$RateViewProfileUser-profile_facebook$"><span id="fbook-add"></span></a></li> </ul> </div> <script type="text/javascript" src="/html_1/js/contact-information.js"></script> Does anyone know why this might error in just IE? Hi, I'm relativly new to JS and brand new to the forum so you might need to dumb down your replys for my slightly lacking knowledge. That being said I do have a very solid grasp of html, css and am getting there with JS and its various frameworks. I'm integrating wordpress into an existing site for a friend and currently have the main blog page appear in a DIV. This is the best way to integrate in this case due to many reasons mostly of way the site is constructed. Code: <div class="scroll-pane" id="scrollbox"> WORDPRESS BLOG </div> My issue is that links within that DIV, in the blog, when clicked redirect the page. The simple answer to this would be to have them just open in a new page, which I can easily do with the below code. Code: function Init() { // Grab the appropriate div theDiv = document.getElementById('scrollbox'); // Grab all of the links inside the div links = theDiv.getElementsByTagName('a'); // Loop through those links and attach the target attribute for (var i=0, len=links.length; i < len; i++) { // the _blank will make the link open in new window links[i].setAttribute('target', '_blank'); } } window.onload = Init; But what I'd rather it do is have any link clicked inside the DIV to reload in that same DIV, similar to an iframe, but obviously without using an iframe, due to it's compatibility issues. Is this possible by editing the above code? If not what do I need? Thanks in advance for any help! var newlink = document.createElement("a"); newlink.setAttribute("class", "mhs uiButton"); newlink.setAttribute("role", "button"); newlink.setAttribute("href", "http://www.facebook.com/#"); newlink.setAttribute("onlick","FriendBrowserCheckboxController.makeFriendRequest(this, '+javaedit.text+'); return false;"); alert(newlink.classname); why alert newlink.classname return as undefined ? i have set class = mhs uiButton already,should be return mhs uiButton? I have the following code Code: <div class="thdnrml"> <td><a href="somelink">fonfof</a></td> </div> what i want to do is this: Code: <div class="thdnrml"> <td><a href="somelink">fonfof</a><a href="anotherlink">another_link</a></td> </div> how can i go about achieving this? |