I have a link:
<a href="javascript:someObject.someFunction();" target="_blank" style="color: rgb(225, 233, 41);">someText</a>
it works fine everywhere except ie(i try ie11) i have this error
This page can’t be displayed.
Make sure the web address //ieframe.dll/dnserror.htm# is correct.
How can i solve this?
If you use a javascript URI scheme in a HTML href attribute, this is different to using an onclick event handler.
In IE, the result of executing that JavaScript will replace the currently loaded document.
To avoid this (without refactoring your code to not do things this way), you can end your href with the javascript operator
void
, which tells your javascript to return nothing, at all (well, undefined).Then IE will stay on the current page.
<a href="javascript:someObject.someFunction(); void 0" ...
...and you probably don't want the
target="_blank"
since you're telling a new window to run your JavaScript code, and your function is not available in that window.I would do this instead:
It will open a new tab as you intended, and it works in chrome, firefox and IE.