JavaScript - Ie Does Not Recognize My Object
i have this javascript code that IE wont recognize any advise please?
Message: Could not get the type property. This command is not supported. Line: 263 Char: 4 Code: 0 Code: function togglePass() { var obj = document.getElementById('pass1'); if (obj.type == 'text') { obj.type = 'password'; } else { obj.type = 'text'; } } Thank you Similar TutorialsHi, I am using jQuery for the following scenario: There is a random number of divs, each sharing the same class (.slecteable), each having its own id (a unique string extracted from the database). A user clicks on a div. I get the id, and change the color of this div (in gets highlighted). Code: $('.selectable').livequery('click',function(){ var id; id = $(this).attr('id'); //change color based on id. }); Now comes the problem. Once a user clicks again on a div, if it wasn't highlighted, it should return to its original color. If it had been highlighted, and had returned to its original color due to a second click, it should get highlighted again. How would you do that? I wish I could post some code, but at this point, it would be rubbish. Thanks in advance. Regards, -jj. Hi there, If I have Ajax bring back a string of HTML, let's say to replace a whole <select> box, does that get registered in the DOM in such a way that I can later manipulate that element via Javascript? It doesn't seem so. I have a <select> box that gets inserted via Ajax but I have a script I want to use to change which <option> is selected after it is loaded in. The client doesn't seem to pick up on the <select> box when I try to call it via getElementById, etc. It came up as unrecognizable as an MD5 hash and it looks like hexadecimal to me. Can someone help me convert it to what it is supposed to say? I think it is a series of numbers but am not entirely sure. Thank you for your assistance. 86a032c42beb25042d8d4dc7970ccc1e I have a div whose CSS I'm setting as follows: Code: div.services_menu { display: none; position: absolute; top: 215px; left: 240px; overflow: hidden; } I also have a initPage function that gets called on pageload: Code: function initPage() { var menu = document.getElementById("services_menu"); var menuItems = menu.getElementsByTagName("div"); alert("top = " + menu.style.top); } The above CSS applies to menu. The alert box tells me: top = So menu.style.top is not set to anything even though I explicitely set it in my CSS. Why is this? Note: I've verified that menu.style.top is still blank even well after the page loads, just to be sure that it's not an issue with CSS being read/processed after the initPage script is read/processed. Here's my script wher problem occurs: Code: $.post('do/register.php?username='+('#username').value, function(result) { if(result == 1) { $('#message').html("Everything's ok"); } else if(result == 2) { $('#message').html("Username is missing."); } else { $('#message').html("What the hell is wrong here?!"); } }); If i put alert(result); in function(result){ } part, i get "result" value that is '1' and that is correct value but it seems like IF statement is not recognizing it at all... #message div constantly shows me "What the hell is wrong here?!" message... Anyone know what could cause this problem? Thanks in advance, phpStud. I am working on my personal portfolio site, and am using a code that will make each portfolio piece appear in a new div when the name of the piece is clicked on. The problem is, JS does not seem to recognize double digits. I am not familiar with JS at all, I just got comfortable with CSS/HTML a few weeks ago! I am in over my head. It would really, really help if someone could show me how to change the code so that I could make about 15 to 20 divs instead of 9. Here is the code: Code: <script language="JavaScript"> numdivs=9 IE5=NN4=NN6=false if(document.all)IE5=true else if(document.layers)NN4=true else if(document.getElementById)NN6=true function init() { showDiv(0) } function showDiv( which ) { for(i=0;i<numdivs;i++) { if(NN4) eval("document.div"+i+".visibility='hidden'") if(IE5) eval("document.all.div"+i+".style.visibility='hidden'") if(NN6) eval("document.getElementById('div"+i+"').style.visibility='hidden'") } if(NN4) eval("document.div"+which+".visibility='visible'") if(IE5) eval("document.all.div"+which+".style.visibility='visible'") if(NN6) eval("document.getElementById('div"+which+"').style.visibility='visible'") } </script> Thank you for taking the time to read this! Hopefully someone can help. Hi, it's my first post and first thread, actually I joined to ask this question. I did try searching first but for some reason when I put this character in google search fields I never find what I want, maybe not being recognized. here's the code Code: this.size=a.size||2000; this.handle_event=a.handle_event||'click'; my question ... what is the || character(s)? I'm sure this must be laughably simple and thanks in advance (new to learning js) Hi there! OK I need a little help as I'm not sure how to integrate this function into my form. First of all I should explain that my form doubles as a Google Search box. If you select the Google Search radio button it submits the input text to Google. It also defaults to Google if anything else other than "red", "green" or "blue" are entered. Now what I'd like to do is add a function so that if someone enters "purple is my favorite color" it recognizes the "purple" part of the string using something like .indexOf('purple'); and calls something like if(function==-1) { theForm.action = "Other choice "+ q.value; . How can I add this to my form? Thank you for any help. My form code: Code: <script> function convert(theForm){ var els = theForm.getElementsByTagName('input');// store inputs var q = els[0], color = els[1]; if(els[4].checked){// submit to google theForm.action = 'http://www.google.com/search'; return true; }; color.value = "Chosen "+ q.value +" color"; switch(q.value){// check the query case 'red': case 'green': case 'blue': location.href = color.value; return false; break; default: theForm.action="http://www.google.com/search"; break; }; return true; }; </script> <form name= "myform" onsubmit='return convert(this)'> <input name='q' type='text' /> <input name='color' type='hidden' /> <input type='submit' value=" Enter " /> <br /> <input name="searchType" type="radio" value="" checked="checked" > <label for="all"> My Form </label> <input name="searchType" type="radio" value="google" onclick="document.myform.action='http://www.google.com/search';" /> <label for="google"> Google Search </label></form> Hi, every time I try and alert: [ { number:0, secondnumber:0 }, { number:2, secondnumber:1 }, { number:1, secondnumber:2 } ] it just shows [object object], [object object], [object object]. Why is this and what can I do to make the record be shown as it is above in an alert? Thanks. I can't get any info from Firebug except that one line, uncaught exception [object Object]. The code fully worked, then I needed to make it dynamically create Sortables from the scriptaculous library based on how many X were in a table in my database, which I've done, and I'm thinking it may be a simple slight parse error of some type, I'm not too good with Javascript, because now my script barely works. I've double checked the script's source code, the PHP variables are exactly what they should be. Code: print<<<HERE Sortable.create('sortlist$box', { tag: 'img', overlap:'horizontal',constraint:false, containment: $list, dropOnEmpty: true, onChange: function(item) { var list = Sortable.options(item).element; if(changeEffect) changeEffect.cancel(); changeEffect = new Effect.Highlight('changeNotification', {restoreColor:"transparent" }); }, onDrop: function(item) { var thing=Sortable.options(item).element.identify(); var anchors = document.getElementById(thing).childNodes.length-2; if(anchors > 20){ alert('This box had 20 creatures in it already, your last action has not been saved.'); window.location.reload(); } else{ new Ajax.Request("saveImageOrder.php", { method: "post", parameters: { data: Sortable.serialize("sortlist$box") } }); } } }); HERE; $box++; } ?> }); </script> if you solve this I'll send ya $10 via paypal I created a method for displaying an object's properties: Code: renderfunction = false; function showProperty (object, property) { document.write ('<td class="type">' + (typeof object[property]) + '</td>' + '<td class="name">' + property + '</td>'); document.writeln('<td class="value">' + ( (typeof object[property] != 'function') ? object[property] :( (property != 'showProperties') ? ( renderfunction ? object[property]() : ('<span class="self">NOT RENDERED</span>') ) : ('<span class="self">THIS</span>') ) ) + '</td>'); document.writeln('<td class="hasOwnProperty" >' + ( object.hasOwnProperty(property) ? "Local" : "Inherited" ) + '</td>'); if (typeof object[property] == 'function') { document.writeln ('<td class="function">' + object[property] + '</td>'); } else { document.writeln ('<td class="function"> </td>'); } } As long as renderfunction = false, the object is fine coming out of this function. However, if I change renderfunction to true, all my properties become undefined. Why isn't this working as I expect it to? How should I fix it? Thanks in advance, -Brian. Hello together! I generate html code with jsp. In that jsp there a several framesets and frames. And yes i know, frames are not really up to date but it's an old program and i have to deal with it now. Anyway, in the top frameset i have an onload attribute like onload="load()". In the function load i want to access the Element.prototype object. But unfortunately typeof Element gives me "undefined". So i looked a little deeper and found that window.toString() gives me "[object]" and not as expected "[object window]" so somehow my window doesn't know that its construcor is Window. window.construcor is "undefined" as well. And i don't have access to the Element object. I really don't know where the error could be. When the page is loaded and i access the same window over the console, then everything is right. But in my function a can't get access to the objects i need. I also don't know what part of the code could be useful to post here, but maybe someone had a similar problem before? i should say that this problem only occurs in IE8. In IE9 it works perfectly. Has anyone any idea?? Ignore post (if mod, please delete)
Hi all, I'm stumped on finding a way in javascript to create an object factory whose instances are also object factories. In short I want something like that below, but no joy ... any clues? Code: function createClass () { return new createClass() function createClass() { return new createInstance () function createInstance () { //Default properties, values and methods which might later be extended } } } var createDoor = createClass(); var door1 = createDoor(); var door2 = createDoor(); var createChair = createClass(); var chair1 = createChair (); var chair2 = createChair (); I'm writing a program that involves a network of interconnected nodes (or simply objects in my example below). It depends on being able to access properties of an object's linked objects (a bit oddly worded, sorry)... Problem is I'm not sure how to properly access those properties... see below please. <script> //This is an example of a problem im having in my own code... //I want to access the name of the object within the links array wintin the object... var objA = {name: "Object A", links: [objB, objC]}; var objB = {name: "Object B", links: [objC, objD, objE]}; var objC = {name: "Object C", links: [objB]}; var objD = {name: "Object D", links: [objE]}; var objE = {name: "Object E", links: [objD]}; //ex: I want to access the name of Object A's first link... console.log(objA.links[0].name); </script> I'm hoping to get "Object B"... But instead I get: TypeError: Result of expression 'objA.links[0]' [undefined] is not an object. Is there another way around this? Any thoughts are appreciated. Hello. Is there any way to get the variable name of an object from inside the object? E.g. PHP Code: function Bla(){ this.write = function(){ document.write(<objectname>); } } obj1 = new Bla(); obj1.write(); //Outputs obj1 Here is my script: PHP Code: function myTimer(seconds, obj){ this.seconds = seconds; this.obj = obj; this.startTimer = function(){ if(this.seconds>0){ this.seconds--; this.obj.innerHTML = this.seconds; this.timer = setTimeout("Timer.start()",1000); } } } Timer = new Timer(10, obj); Timer.startTimer(); Now the problem is that the variable that contains the object must be named "Timer". This way I cannot create new timer objects with different variable names I have tried: this.timer = setTimeout("this.start()",1000); but it doesn't work. That's why it would be good to detect the variable name and instead use something like this: this.timer = setTimeout(varname+".start()",1000); I would rather not have to pass the variable name through a parameter like this: Timer1 = new Timer(10, obj, "Timer1"); Thanks in advance. Quote: menu: function( a, b ) { $( b ).observe( 'click', function( event ) { event.stop(); if( $( a ).visible() ) { $( a ).hide(); $( b ).removeClassName( 'selected' ); document.stopObserving( 'click' ); } else { $( a ).show(); $( b ).addClassName( 'selected' ); document.observe( 'click', function( e ) { if( e.target.id != a && e.target.id != b && !Element.descendantOf( e.target, $( a ) ) ) { $( a ).hide(); $( b ).removeClassName( 'selected' ); document.stopObserving( 'click' ); } }); } }); $$( '#' + b + ' > a' ).each( function( element ) { element.observe( 'click', function( event ) { $( a ).hide(); $( b ).removeClassName( 'selected' ); document.stopObserving( 'click' ); }); }); } This work's perfrect accept when i use it with others on the menu it leaves the other ones open, how do i get it to close the open one when i open a new menu.. Thanks. I am trying to troubleshoot my javascript function below. Code: <script type="text/javascript"> function txtboxfill(fillobj) { var rChar=String.fromCharCode(13); var myVal = "To: " + this.form.to.value + rChar; myVal = myVal + "From: " + this.form.from.value + rChar; myVal = myVal + "Subj: " + this.form.subj.value + rChar + rChar; myVal = myVal + "Message: "; fillobj.value = myVal; } </script> Then I have a text box input field with an Code: <input type="text" id="tp" name="to" size="34" class="totext" onkeyup="txtboxfill(this.form.msg_area);"> and when I enter text in this field it gives me a 'this.form.to' is null or not an object and does not populate the textarea. BTW, msg_area is the id of my textarea. Thank you. Code: function globals() { this.states = ""; } now I can: Code: globals.states = .... how to extend first code to be able: Code: globals.states.something = .... ? |