JavaScript - Ie Version Of Setattribute
Code:
closeElement.setAttribute('onClick', 'killElement()'); is not working in IE but works in mozilla browsers what is the appropriate IE version for the similar code? i've also tried: Code: closeElement.onclick = 'killElement()'; Similar TutorialsHaving some issues with setAttribute() and IE6, works in other browsers just being illusive in IE6. Any help here would be great. Currently using IETester v0.4.6. Stylez. Code: <div id="Element">Element</div> <script> document.getElementById("Element").setAttribute('onclick', 'alert("!")'); </script> Hi, How can I set textarea setAttribute value in FireFox. When I print my form it doesn't print any thing inside FireFox. It prints it blank. Code: var AddlInfo= IntakeForm.getElementsByTagName('textarea')[0]; AddlInfo.setAttribute("value",AddlInfo.value); Thanks. Everything works but I'm afraid that it might be slow due to my heavy use of setAttribute for my dynamically created buttons. This is the only place I've needed it because I was able to use this bit of code Old Pedant came up with. Here's what I'm trying to improve upon Code: span.setAttribute("onMouseOver","ShowPage(type_num,\"all\",1);ShowPage(type_num,\"y"+z+"\",1);"); Quote: Originally Posted by Old Pedant Code: xxx.setAttribute("itemnum",itemnum); xxx.onclick = function() { return showRapidText(this.getAttribute("itemnum")); }; I don't understand how to apply that ^ to this > Code: span.setAttribute("onMouseOver","ShowPage(type_num,\"all\",1);ShowPage(type_num,\"y"+z+"\",1);"); My working version is here ... and the next bit is what I've tried and had no success with. Code: for (z=1920; z<=2010;z++){ var li = document.getElementById("Dynamic_Year_Filter_Reference"); var span = document.createElement("SPAN"); var text = document.createTextNode(z); span.id = "y"+z+"_mainmenuimg" span.className = "mainmenuimgyear" span.setAttribute("onMouseOver","ShowPage(type_num,\"all\",1);ShowPage(type_num,\"y"+z+"\",1);"); span.setAttribute("onMouseDown","l_num=\"y"+z+"\";pg_num=1;ShowPage(type_num,l_num,pg_num);"); span.setAttribute("onMouseOut","ShowPage(type_num,l_num,pg_num);"); li.appendChild(span).appendChild(text) } } Code: span.setAttribute("type_num", type_num); span.onmouseover = function() { ShowPage(this.getAttribute("type_num"),"all",1);ShowPage(this.getAttribute("type_num"),"y"+z+"",1); }; Im writing a piece of javascript that dynamically adds a link to a page, this is the code i'm using Code: var newP; newP = document.createElement("a"); newP.innerHTML = "Click here"; newP.setAttribute("href","http://mywebsite.com/link.html"); var p2 = document.getElementById("Div1"); p2.parentNode.insertBefore(newP,p2); However, it wont work?!?! the link appears in the right place on the page when i remove the line Code: newP.setAttribute("href","http://mywebsite.com/link.html"); and if i view the source the link is <a>Click here</a> (without any href) so there's got to be something wrong with that line but i don't know what it is. Can anyone help me? How do i add a href to the anchor?? I'm using firefox. The latest version of MSIE fails to read the value of a popup menu in a form that I have. It worked fine in a previous version, and works in Firefox and Mac Safari. Here is an edited version of what I have: Code: var d = null; function myTest(){ alert("mWunits value = ".concat(d.mWunits.value)) } . . . <body onload="d = document.forms[0];"> . . . <form onsubmit="return false" > <table align="center" border="0"> <tbody> <tr> <td align="right">Conductor Size (d):</td> <td><input name="ef_dw" size="12"> </td> <td align="left"> <select name="mWunits" size="1"> <option selected="selected">mm</option> <option>AWG</option> </select> </td> </tr> . . . The popup name is mWunits, and should have either "AWG" or "mm" as a value. And the function myTest() should display that value. However the value is an empty string. There is another popup in the same form, and it exhibits the same problem. My script reads the values of regular input fields just fine. As I said, this used to work under earlier MSIE versions, and works in other browsers. Has something been deprecated that I don't know about? Hi, i have a rating script which shows 5 stars and it allows users to vote out of 5 on certaiin things, the votes register ok but the stars dont change colour to show that the user has voted. this has happened since my host upgraded to php 5.3 and i noticed on IE(which i never use much) it says there is an error on the page and that error says Code: Webpage error details User Agent: Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 6.1; Trident/4.0; SLCC2; .NET CLR 2.0.50727; .NET CLR 3.5.30729; .NET CLR 3.0.30729; Media Center PC 6.0) Timestamp: Tue, 2 Feb 2010 20:00:42 UTC Message: 'document.all[...]' is null or not an object Line: 96 Char: 9 Code: 0 URI: rating.js line 96 in the related file is Code: } else if(IE) { document.all[div2show].innerHTML = text; } which only related to IE and not firefox so im unsure why my rating graphics do not show once selected. here is the entire js file is there anything in there that might be preventing it? Code: /* Page: rating.js Created: Aug 2006 Last Mod: Mar 11 2007 Handles actions and requests for rating bars. --------------------------------------------------------- ryan masuga, masugadesign.com ryan@masugadesign.com Licensed under a Creative Commons Attribution 3.0 License. http://creativecommons.org/licenses/by/3.0/ See readme.txt for full credit details. --------------------------------------------------------- */ var xmlhttp /*@cc_on @*/ /*@if (@_jscript_version >= 5) try { xmlhttp=new ActiveXObject("Msxml2.XMLHTTP") } catch (e) { try { xmlhttp=new ActiveXObject("Microsoft.XMLHTTP") } catch (E) { xmlhttp=false } } @else xmlhttp=false @end @*/ if (!xmlhttp && typeof XMLHttpRequest!='undefined') { try { xmlhttp = new XMLHttpRequest(); } catch (e) { xmlhttp=false } } function myXMLHttpRequest() { var xmlhttplocal; try { xmlhttplocal= new ActiveXObject("Msxml2.XMLHTTP") } catch (e) { try { xmlhttplocal= new ActiveXObject("Microsoft.XMLHTTP") } catch (E) { xmlhttplocal=false; } } if (!xmlhttplocal && typeof XMLHttpRequest!='undefined') { try { var xmlhttplocal = new XMLHttpRequest(); } catch (e) { var xmlhttplocal=false; alert('couldn\'t create xmlhttp object'); } } return(xmlhttplocal); } function sndReq(vote,id_num,ip_num,units) { var theUL = document.getElementById('unit_ul'+id_num); // the UL // switch UL with a loading div theUL.innerHTML = '<div class="loading"></div>'; xmlhttp.open('get', 'rpc.php?j='+vote+'&q='+id_num+'&t='+ip_num+'&c='+units); xmlhttp.onreadystatechange = handleResponse; xmlhttp.send(null); } function handleResponse() { if(xmlhttp.readyState == 4){ if (xmlhttp.status == 200){ var response = xmlhttp.responseText; var update = new Array(); if(response.indexOf('|') != -1) { update = response.split('|'); changeText(update[0], update[1]); } } } } function changeText( div2show, text ) { // Detect Browser var IE = (document.all) ? 1 : 0; var DOM = 0; if (parseInt(navigator.appVersion) >=5) {DOM=1}; // Grab the content from the requested "div" and show it in the "container" if (DOM) { var viewer = document.getElementById(div2show); viewer.innerHTML = text; } else if(IE) { document.all[div2show].innerHTML = text; } } /* =============================================================== */ var ratingAction = { 'a.rater' : function(element){ element.onclick = function(){ var parameterString = this.href.replace(/.*\?(.*)/, "$1"); // onclick="sndReq('j=1&q=2&t=127.0.0.1&c=5'); var parameterTokens = parameterString.split("&"); // onclick="sndReq('j=1,q=2,t=127.0.0.1,c=5'); var parameterList = new Array(); for (j = 0; j < parameterTokens.length; j++) { var parameterName = parameterTokens[j].replace(/(.*)=.*/, "$1"); // j var parameterValue = parameterTokens[j].replace(/.*=(.*)/, "$1"); // 1 parameterList[parameterName] = parameterValue; } var theratingID = parameterList['q']; var theVote = parameterList['j']; var theuserIP = parameterList['t']; var theunits = parameterList['c']; //for testing alert('sndReq('+theVote+','+theratingID+','+theuserIP+','+theunits+')'); return false; sndReq(theVote,theratingID,theuserIP,theunits); return false; } } }; Behaviour.register(ratingAction); many thanks for any help Luke all, does anyone know if the setTimeout() function in js has been just recently supported? i created an online demonstration of a product that uses this function to delay the playing of .wav files after various second intervals. i know that Opera doesn't support this function because when I click my button, all of the .wav files that i have in the function that runs behind the button play at once. i have probably 10 wav files that are played throughout the function, at various conditional statements. does anyone know if earlier (like REALLY old) versions of IE do not support this function? or maybe ie8 doesn't support it? i developed this and tested it in all major browsers except IE8 and any version earlier than IE6. thank you for any help on this... Some background might better help my actual problem. Feel free to address either with any relevant insights. While attempting to create a greasemonkey script in FF2 (don't ask), I discovered that the "let" statement was causing my code to fail. After confirming that this statement has been available since FF2 (js engine 1.7) https://developer.mozilla.org/en/New_in_JavaScript_1.7, I became curious as one determines their javascript engine in FF. IE has a way to inspect the jscript engine, ala http://msdn.microsoft.com/en-us/libr...8VS.80%29.aspx , but I couldn't find anything similar for FF. Feel free to list links for testing engines in other browsers, too. I can't use irc at work, so it's good to know this place is still around for numb-nuts like me. :-) Many, many thanks (in-advance). i don't know what has changed in last releases of Firefox and Opera but before i used this script to detect browser versions (IE, Opera, FF) and block or redirect depending on version Code: <script language="javascript"> <!-- //Detect IE greater than 1 - we are blocking it completely version=0 if (navigator.appVersion.indexOf("MSIE")!=-1){ temp=navigator.appVersion.split("MSIE") version=parseFloat(temp[1]) } if (version>1) window.location="ie-error.html" //Detect Opera less than 10 (9.80) if (navigator.userAgent.indexOf("Opera")!=-1){ var versionindex=navigator.userAgent.indexOf("Opera")+6 if (parseInt(navigator.userAgent.charAt(versionindex))<9.8) window.location="op-error.html" else (window.location="index2.html") } //Detect Firefox less than 3.6 if (navigator.userAgent.indexOf("Firefox")!=-1){ var versionindex=navigator.userAgent.indexOf("Firefox")+8 if (parseInt(navigator.userAgent.charAt(versionindex))<3.6) window.location="ff-error.html" else (window.location="index2.html") } // --> </script> it worked last with Opera 9.5, FF 3.0 but after that it doesnt work at all Firefox'es version (3.6) doesn't get detected and is redirected to error page same goes with Opera (9.8 which is 10.0-10.5) can anyone tell me why this happens ? or can anyone "fix it" i know many people are against this kind of scripts (blockers and redirecters) but i do it so people who come with older and less compatible browsers with W3C standards to get warned so they don't load deformed page Hello to all, I think that you will frequently read this boring sentence: "Javascript does not work with Firefox". Below a very very simple html with Javascript. Using MS IE v8 I have found that the code works very well. Filling nothings in the textfield "your name" and subsequently clicking on the button and a window will popup with the text "Sorry, you forget to: blah-blah ..." However, using Firefox instead...it does not work. A bit remarkable; the Javascript is very easy! Could you please check what went wrong? I have activated Javascript in the Firefox browser and the security is ok for Javascript. I hope that someone can provide me a useful hint. Best regards, Cornelis The Netherlands - Gouda (yes, the town where cheese is inherently linked) [CODE] <html> <head> <meta http-equiv="Content-Language" content="nl"> <meta http-equiv="Content-Type" content="text/html; charset=windows-1252"> <title>Inloggen van een nieuw lid</title> <script language = "Javascript"> function checkDate() { var message = "Sorry, you forget to: \n"; var voornaam = document.getElementById("voornaam"); var result = true; if (voornaam.value.length == 0) { message+="- You have not typed your name\n"; result = false;} if(!result) {alert(message)}; return result; } </script> </head> <body> <FORM METHOD="post" name=CheckDate onsubmit="return checkDate(this);" > <div style="position: absolute; width: 603px; height: 378px; z-index: 1; left: 30px; top: 13px" id="laag1"> <p align="center"><font face="Trebuchet MS" color="#00750F" size="5"><b> Test</b></font></p> <table border="0" width="100%" bgcolor="#C4FFC4" style="border-collapse: collapse" id="table3"> <tr> <td> </td> </tr> </table> <p align="left"> </p> <table border="0" width="69%" id="table1" height="210" style="border-collapse: collapse"> <tr> <td width="37%"><font face="Trebuchet MS">your name</font></td> <td width="59%"> <p align="center"><input type="text" name="voornaam" size="25"></td> </tr> <tr> <td colspan="2" height="90"> <p align="center"> <input type="submit" value="Register me" name="Registreren"> </td> </tr> </table> <p> </p> </div> </body> </form> </html> Hi all, I'm currently working on a page that is presented to users which will check browser version, OS version etc. I've managed to do all of these checks with JavaScript but I'm struggling to find out how (or even IF) I can get what version of Windows Media Player the user has installed. We're looking to see if they have WMP11 or greater. The searching I've done has thrown up a couple of things (like a check to see if the version is 5.2 or 6.4 or higher by looking at mimeTypes). Basically can anyone confirm if this is actually possible and if so any pointers would be appreciated. Thanks in advance I need a script that will redirect to a specific page is the browser is safari version 4. if the browser is NOT safari 4 I want the browser to stay on the current page.
Hi All, I have two sites using zeroclipboard (hosted at google code) one works only in firefox and barely, the other is not working at all. It does use Flash, but I think the issue is on the js side of things. On both links, clicking the filename below the thumbnail will copy and add the link as an IMG code to a div below. *working* link http://pics.boasbysatyra.com/access/spiders.php This one only works in FF, and the clip area is offset badly. Here is the template for the zc code: Code: <div class="photo" style="float: left; padding: 4px;"> <div class="exif"><a href="[~41~]?dir=[+images_dir+]&file=[+filename+]" rel="shadowbox[exif_[+content_id+]]" title="exif data for [+filename+]" alt="exif data for [+filename+]">EXIF Data</a></div> <a class="thumb" rel="shadowbox[[+content_id+]]" href="[+images_dir+][+filename+]" title="[+title+] | [+description+]"> <img src="[+thumbs_dir+][+filename+]" alt="[+title+]" /> </a> <div class="filecode" id="d_clip_button[+filename+]">[+filename+] <script language="JavaScript"> var clip = new ZeroClipboard.Client(); clip.setText( 'http://pics.boasbysatyra.com[+images_dir+][+filename+]' ); clip.glue( 'd_clip_button[+filename+]' ); clip.addEventListener( 'onComplete', my_complete ); function my_complete( client, text ) { $('.picklist').append('<div class="piclinks">[IMG]' + text + '[/IMG]</div>'); } </script> </div> </div> And the JS for the page: Code: var needRef; //flag for page reload function pEdit(){ needRef = 1; } Shadowbox.init({ handleOversize: "resize", modal: true, initialHeight: 32, initialWidth: 400, overlayOpacity: 0.85, onClose: function(){//check for reload flag and reload if (needRef == 1){window.location.href=window.location.href;} } }); ZeroClipboard.setMoviePath('/js/zc/ZeroClipboard10.swf'); function initMenu() { $('#menu ul').hide(); $('#menu ul:first').show(); $('#menu li a').click(function() { var checkElement = $(this).next(); if ((checkElement.is('ul')) && (checkElement.is(':visible'))) { //return false; } if ((checkElement.is('ul')) && (!checkElement.is(':visible'))) { $('#menu ul:visible').slideUp('normal'); checkElement.slideDown('normal'); return false; } }); } $(document).ready(function() { initMenu(); }); Now on to the totally broken one - it creates the elements required, but gives them a 0x0 area! http://jb.boasbysatyra.com/forum-pic...cs/nature.html Code: div class="photo" style="float: left; margin: 4px;"> <div class="exif"><a href="[~133~]?dir=[+images_dir+]&file=[+filename+]" rel="shadowbox[exif_[+content_id+]]" title="exif data for [+filename+]" alt="exif data for [+filename+]">EXIF Data</a></div> <a class="thumb" rel="shadowbox[[+content_id+]]" href="[+images_dir+][+filename+]" title="[+title+] | [+description+]"> <img src="[+thumbs_dir+][+filename+]" alt="[+title+]" /> </a> <div id="d_clip_container[+filename+]" style="position:relative; width: 120px; height: 0.5em;"> <div class="filecode" id="d_clip_button[+filename+]">[+filename+] <script language="JavaScript"> var clip = new ZeroClipboard.Client(); clip.setText( 'http://jb.boasbysatyra.com[+images_dir+][+filename+]' ); clip.glue( 'd_clip_button[+filename+]','d_clip_container[+filename+]' ); clip.addEventListener( 'onComplete', my_complete ); function my_complete( client, text ) { $('.picklist').append('<div class="piclinks">[IMG]' + text + '[/IMG]</div>'); } </script> </div> </div> </div> On this one I wrapped it as suggested on the zc site, I originally started with the code for the other site - it didn't work, so I went tweaking... Here is the JS: Code: var needRef; //flag for page reload function pEdit(){ needRef = 1; } Shadowbox.init({ handleOversize: "resize", modal: true, initialHeight: 32, initialWidth: 400, overlayOpacity: 0.85, onClose: function(){//check for reload flag and reload if (needRef == 1){needRef = 0; window.location.href=window.location.href;} } }); ZeroClipboard.setMoviePath('/js/zc/ZeroClipboard10.swf'); $(document).ready(function() { $(".dim img").fadeTo("slow", 0.65); $(".dim img").hover(function(){ $(this).fadeTo("slow", 1.0); },function(){ $(this).fadeTo("slow", 0.65); }); $('#mainContent').hide().fadeIn(1200); //When page loads... $(".tab_content").hide(); //Hide all content // $("ul.tabs li:first").addClass("active").show(); //Activate first tab // $(".tab_content:first").show(); //Show first tab content //On Click Event $("ul.tabs li").click(function() { $("ul.tabs li").removeClass("active"); //Remove any "active" class $(this).addClass("active"); //Add "active" class to selected tab $(".tab_content").hide(); //Hide all tab content var activeTab = $(this).find("a").attr("href"); //Find the href attribute value to identify the active tab + content $(activeTab).fadeIn(); //Fade in the active ID content return false; }); }); (function($) { $(document).ready(function(){ $('.menu1').ptMenu(); $('.menu2').ptMenu({vertical:true}); }); })(jQuery); I have taken a look at this for a few days and tried many things with no luck, any help is appreciated. Thanks! Hello, I have a question what is the best way to identify a browser, browser version and OS in javascript. I have try a few scripts but they all fail. This will help me out formating the code for diferent browsers. Thanks |