At the moment I have the below code on a website
*global escape: true */
var twitterHandle = "Handle";
function tweetCurrentPage() {
return window.open("https://twitter.com/share?url="+escape(window.location.href) + "&text=" + document.title + " via #" + twitterHandle, "", "menubar=no,toolbar=no,resizable=yes,scrollbars=yes,height=300,width=600"), !1;
}
Internet Explorer F12 Debugger at the moment throws up the following error.
The value of the property 'tweetCurrentPage' is null or undefined, not a Function object.
Works fine on Chrome, Safari and Edge but not on IE11 nor Firefox - any help would be appreciated. I have put the code through various online bug checkers and so on. Only error they have come up with is Function is not called... but I call the function in other ways.
Related
HTML5 speech is not working on Safari on a mac 10.0.1,
I get the error,
TypeError: Argument 1 ('utterance') to SpeechSynthesis.speak must be
an instance of SpeechSynthesisUtterance
It works on Chrome and Firefox, and I'm pretty sure it used to work on Safari...
var u = new SpeechSynthesisUtterance();
u.text = "hello world";
u.lang = "en";
window.speechSynthesis.speak(u);
Okay, finally figured it out.
I had some compatibility code to support browser without html5 speech,
if (SpeechSynthesisUtterance == undefined) {
function SpeechSynthesisUtterance(text) {
this.text = text;
}
}
This works on Chrome and Firefox, but on Safari it seems that any function in any script is evaluated when the script is parsed, so the function get declared even though SpeechSynthesisUtterance already exists.
Guess I'll need to do this differently...
I hope this is something simple..
I am using the F12 Development tool debugger in IE 9. Is there a way I can display the line numbers and file source for each console statement, the same way that Firebug displays this info? I may have overlooked something basic, but I haven't yet found a way to do this..Thanks!
The only way to get line numbers is to define a window.onerror method:
window.onerror = function (message, url, lineNo)
{
console.log('Error: ' + message + '\n' + 'Line Number: ' + lineNo);
return true;
}
console.log(window);
console.log(1=2);
But even then, IE breaks on the error, so it's rather useless.
Is there a way to retrieve the line number from an Internet Explorer 7/8 error object?
I'm only aware of the .message, .description and .number properties.
I've searched around a bit and found an MSDN article on .stack ( http://msdn.microsoft.com/en-us/library/hh699850(v=vs.94).aspx ), but even using their own example code doesn't return a line number:
http://jsfiddle.net/LWevS/
I dug around some more and found that it is possible to retrieve the line number in IE using window.onerror. It's not from the Error object itself, but it's a decent workaround:
function BadFunction(){
This.badcode.willnot.work = 1000
}
function ForceError(msg, url, lno) {
alert("Error Occurred! Handled by Generic Error Handler" + "\n" +
"Error: " + msg + "\n" + "URL: " + url + "\n" +
"Line Number: " + lno);
return true;
}
window.onerror = ForceError;
This method requires that the error bubble up to the window. If you have a try/catch in your code, you will need to re-throw the error so it can bubble up.
I also came across StackTraceJS on GitHub while researching a solution to this problem. Their stack tracing script works great on all browsers except for Internet Explorer. A great run-time debugger if you want to log errors produced on the client browser.
http://stacktracejs.com/
I am using Ajax via ICallbackEventHandler in ASP.NET, what happens on the page is that a recursive call is made back to the server every 1000ms using ajax. Here is the code that makes a ajax callback every 1 second:
setTimeout("MessageServerRequest(tempLastDate);", 1000);
function MessageServerRequest(param)
{
WebForm_DoCallback('ChannelControl1','getmessage~' + param,MessageServerResponse,null,null,true);
}
function MessageServerResponse(param, context)
{
if (param.length > 0) {
var splitParam = param.split("~");
var id = splitParam[0];
var messagesHtml = splitParam[1];
var lastDate = splitParam[2];
tempLastDate = lastDate;
$('#' + id).prepend(messagesHtml);
}
setTimeout("MessageServerRequest(tempLastDate);", 1000);
}
What this does is that it gets all the latest messages from the database and returns the new messages back to the client.
Now when i removed the recursive call, IE didnt crash, but the thing is that when i use Mozilla, Safari or Opera everything works fine with the recursive call being used.
I dont understand why its working for all other browsers and not IE 8/9
System Info
Windows 7 ultimate
32 bit
visual studio 2006
IE9, even didnt work with IE8 but i upgraded to IE9
Can anyone help me with this issue please, i would be greatful?
Thanks
I create an error message its working with IE and Mozila.
Not woking with Safari, Chrome and Opera.
But I need to use it. Please give me right way for doing it.
<script language="javascript" type="text/javascript">
window.onerror = function(msg, url, line)
{
document.write("Message\t = "+msg + "<br/>Location\t = " + url + "<br/>Line No.\t = " + line + "<br/>Error No.\t = " + this.err.number);
}
this.err = Error(12,"My Own Error");
throw this.err;
</script>
==========================================
Internet Explorer:
My Error
Message = My Own Error
Location = http://localhost/practice/JavaScript/window.errors.php
Line No. = 8
Error No. = 12
================================================
Mozilla FireFox:
My Error
Message = Script error.
Location = My Own Error
Line No. = 0
Error No. = undefined
=====================================================
Safari, Chrome, Opera:
My Error
look the code Mozilla give wrong information. what I do?
Opera doesn't support window.onerror at all. Chrome supports it, but not on errors that you throw yourself. This is also true of Internet Explorer when using Error objects other than Error(), e.g. TypeError(). Chrome also doesn't provide the line and file arguments.
You should correctly catch any exceptions you're going to throw with a try...catch statement, instead of relying on window.onerror.