I have a <textarea> defined like this:
<textarea class="form-control notetext" id="{{this._id}}-notetext" name="notetext">{{this.text}}</textarea>
I use ajax to send data and load a partial webpage.
Then I try to find the <textarea> and list the results to the console.
The problem is that elements[0] is returning undefined in Internet Explorer 11 (haven't tried any other versions), but works fine in Chrome and Firefox. I have tried 3 variations which all give the same result. Is there a solution?
$.get('/page/' + Id + '/partial/', function(res) {
$('#sectional').html(res);
//variation 1
var elements = document.getElementsByClassName('notetext');
//variation 2
var elements = document.querySelectorAll('.notetext');
//variation 3
var elements = document.getElementsByTagName("textarea");
});
Also, please note that id is dynamically created, so I can't .getElementById (which would only return 1 result instead of an array). I saw a post somewhere that had a method to use regex on .getElementById, but it returned null as well.
...and it turned out that it was working in IE11 after all. I was originally using getElementsbyName which doesn't work properly in IE11 (it gets ID instead). So I changed it to the variations listed above, which all gave the same incorrect result. But after I quit and restarted the browser, the code worked fine. I'm not sure if I can change a setting somewhere in IE so this doesn't happen again?
IE8 has been throwing this error at me
SCRIPT65535: Unexpected call to method or property access.
load-scripts.php, line 4 character 25690
I removed a .js file from the code, and the error went away. I started commenting functions out, and narrowed it down to this one. With this one commented, I don't get the error. With it active, I do get it
$("title, .ab-item").each(function() {
var text = $(this).text();
text = text.replace("RepAgent", "Review Scout");
$(this).text(text);
});
I've used JSHint and it says that it's valid?
I'm pretty sure that Internet Explorer doesn't like you messing with <title> element contents. That's not really how you set the document title anyway; just set document.title.
jQuery uses appendChild inside $.text() .
Although <title/> has a appendChild-method(inherited from HTMLElement), this method may not be used.(it's also not listed in the title-methods)
I was trying to make a slide show gallery and used the example at URL - http://mediaeventservices.com/2007/11/15/ajax-image-gallery-powered-by-slideflow-like-cover-flow/
When I view it in FF it works fine however IE and chrome give me an error:
“is null or not an object”.
Message: Object required
Line: 66
Char: 2
Code: 0
URI: file:///C:/Romona/P%20drive%20backup/componets/slideShow/slideShow4/slideShowGallery/gallery.html
IE developer tools indicate that the below line is causing the problem:
var imgSrc = ‘photos/large/’+ photos.item(photoNumber – 1).getElementsByTagName(“src”)[0].childNodes[0].nodeValue;
Does anyone have any suggestions?
Thank you
First of all, i hope your real code doesn't have smart quotes “src” and has dumb quotes instead "src".
Second, getElementsByTagName("src") isn't going to work. That will find <src> tags. But you probably want <img> tags instead, so search for "img" instead.
I think getElementsByTagName("src") returns an empty array because nothing is found, getting the first item with [0] returns null, and calling childNodes on null raises this error.
At the very least, try breaking that line up and see what steps return something you don't expect.
I am receiving the following error in IE which is stopping the page from loading. I have tried to find this error but for the life of me cannot see it. The portion of the code that the error points to is here at jsfiddle.net:
http://jsfiddle.net/SrgsC/
I would be grateful if someone could point out the offending error? Many thanks
I am using php5.3.5
Message: Expected ')'
Line: 2867
Char: 41
Code: 0
URI: http://sample.com/admin/cp.php
Message: Expected ')'
Line: 2867
Char: 40
Code: 0
URI: http://sample.com/admin/cp.php
Well, the code you provided is in PHP, not JavaScript. If this is only happening in IE, then it is clear that you have put a PHP function in a JavaScript file. Otherwise, it should be happening in IE, FF, Chrome...
Some issues with the PHP function at any rate:
you start with $print .= . This means, "add the following string to the $print" variable, but $print is not defined in that function. If it is a global variable, you need to put global $print; on the line before it, or, if it is local, then you need to use $print = (no '.')
mysql_numrows should be mysql_num_rows unless you've created your own numrows function
mysql_result should not be used that way. To quote the docs:
When working on large result sets, you should consider using one of the functions that fetch an entire row
You should not be manually iterating through rows by tracking the current row number (the same reason as above)
A 15 parameter function is too many. It is way to many. The maximum which can be handled effectively are 7 (according to Code Complete), the more zealous would argue for even fewer (Uncle Bob, I believe, says 3 is a good standard). Either way, if I saw 8 or more parameters in a method during a code review I would immediately know something needed to change.
I have a site that has an IE8-only problem:
The code is:
var w = window.open(urlstring, wname, wfeatures, 'false');
The error is:
Message: Invalid argument.
Line: 419
Char: 5
Code: 0
URI: http://HOSTNAME/js_context.js
I have confirmed the line number of the code (the "Line" and "URI" are correct), and I understand in later versions of IE8, this is considered accurate.
I have checked all the incoming parameters in the call by dumping alerts, and they all look valid.
This problem does not happen on FF (probably 3).
UPDATE:
The problem appears to be in using assigning the result of window.open() when doing "var w". When I split the line into two statements it works in IE8.
UPDATE2:
Based on:
http://javascript.crockford.com/code.html
When a function is to be invoked
immediately, the entire invocation
expression should be wrapped in parens
so that it is clear that the value
being produced is the result of the
function and not the function itself.
This is not exactly what is going on here, but I found that applying the principle solved the problem, in IE8's compatability mode.
var w = (window.open(urlstring, wname, wfeatures, false));
This is an old posting but maybe still useful for someone.
I had the same error message. In the end the problem was an invalid name for the second argument, i.e., I had a line like:
window.open('/somefile.html', 'a window title', 'width=300');
The problem was 'a window title' as it is not valid. It worked fine with the following line:
window.open('/somefile.html', '', 'width=300');
In fact, reading carefully I realized that Microsoft does not support a name as second argument. When you look at the official documentation page, you see that Microsoft only allows the following arguments, If using that argument at all:
_blank
_media
_parent
_search
_self
_top
IE is picky about the window name argument. It doesn't like spaces, dashes, or other punctuation.
When you call window.open in IE, the second argument (window name) has to be either one of the predefined target strings or a string, which has a form of a valid identifier in JavaScript.
So what works in Firefox: "Job Directory 9463460", does not work in Internet Exploder, and has to be replaced by: "Job_Directory_9463460" for example (no spaces, no minus signs, no dots, it has to be a valid identifier).
the problem might be the wname, try using one of those shown in the link above, i quote:
Optional. String that specifies the
name of the window. This name is used
as the value for the TARGET attribute
on a form or an anchor element.
_blank The sURL is loaded into a new, unnamed window.
_media The url is loaded in the Media Bar in Microsoft Internet
Explorer 6. Microsoft Windows XP
Service Pack 2 (SP2) and later.
This feature is no longer
supported. By default the url is
loaded into a new browser window or
tab.
_parent The sURL is loaded into the current frame's parent. If the frame has no parent, this value acts as the value _self.
_search Disabled in Windows Internet Explorer 7, see Security and Compatibility in Internet Explorer 7 for details. Otherwise, the sURL is opened in the browser's search pane in Internet Explorer 5 or later.
_self The current document is replaced with the specified sURL.
_top sURL replaces any framesets that may be loaded. If there are no framesets defined, this value acts as the value _self.
if using another wname, window.open won't execute...
Actually a name can be used however it cannot have spaces so
window.open("../myPage","MyWindows",...) should work with no problem (window.open).
I also meet this issue while I used the following code:
window.open('test.html','Window title','width=1200,height=800,scrollbars=yes');
but when I delete the blank space of the "Window title" the below code is working:
window.open('test.html','Windowtitle','width=1200,height=800,scrollbars=yes');
Hi using the following code its working...
onclick="window.open('privacy_policy.php','','width=1200,height=800,scrollbars=yes');
Previously i Entered like
onclick="window.open('privacy_policy.php','Window title','width=1200,height=800,scrollbars=yes');
Means Microsoft does not allow you to enter window name it should be blank in window.open function...
Thanks,
Nilesh Pangul
For me the issue was with a dash "-" in the window name field. I removed the dashes and IE does not error out and in fact opens the window.
What does position four represent, the one that has 'false' as an value? Shouldn't that be false, (i.e. without quotes?). It's possible that earlier versions of IE would coerce the string to a boolean, but newer ones don't.
The answers here are correct in that IE does not support spaces when setting the title in window.open(), none seem to offer a workaround.
I removed the title from my window.open call (you can use null or ''), and hten added the following to the page being opened:
<script>document.title = 'My new title';</script>
Not ideal by any means, but this will allow you to set the title to whatever you want in all browsers.
Try remove the last argument. Other than that, make sure urlstring, wname, and wfeatures exist.
I discovered the same problem and after reading the first answer that supposed the problem is caused by the window name, changed it : first to '_blank', which worked fine (both compatibility and regular view), then to the previous value, only minus the space in the value :) - also worked. IMO, the problem (or part of it) is caused by IE being unable to use a normal string value as the wname. Hope this helps if anybody runs into the same problem.
If you want use the name of new window etc posting a form to this window, then the solution, that working in IE, FF, Chrome:
var ret = window.open("", "_blank");
ret.name = "NewFormName";
var myForm = document.createElement("form");
myForm.method="post";
myForm.action = "xyz.php";
myForm.target = "NewFormName";
...
It seems when even using a "valid" custom window name (not _blank, etc.) using window.open to launch a new window, there is still issues. It works fine the first time you click the link, but if you click it again (with the first launched window still up) you receive an "Error: No such interface supported" script debug.