Javascript replace error in Safari on some sites - javascript

If you go to https://www.artistguitars.com.au on safari 12 ,open console and enter:
x='%str%';
x.replace (/%str%/g, '$15');
you will get '5' instead of $15
On other browsers it works well.
Why is that? I could not find information anywhere.

Related

Disable a plugin for IE 11 only

There's a hamburger menu that the client wants to keep, however the site is very broken ... only in iE 11.
https://lavidaapartments.com
Is there any way to fix these errors I found in the console for IE 11?
SCRIPT1028: Expected identifier, string or number
iwpmenu.js (30,21)
SCRIPT438: Object doesn't support property or method 'iwpmenu'
wp_iwpmenu.js (2,5)
Thank you in advance for any suggested solution.
Your site is generating an error on this File: iwpmenu.js, Line: 30, Column: 21, which maps to:
jQuery('#iwpmenu_bar').delay(delayval).removeClass('open').animate({
[direction]: [direction_width_minus] -- Expected identifier, string or number
}, options.close_bar_delay, function() {
jQuery(this).css('display', '').find("ul.menu").css("padding-left", "20px");
});
The error happens because IE11 does not support computed property keys, more information here.
Thanks to bastos.sergio, the answer is to eliminate the syntax from the plugin.
Since I'm not a programmer, I hope to find someone that can make it happen for us.
Thank you!

element.select() doesn't work in Firefox

I have a test where I go to Google.com and run the following commands in the console:
test = document.querySelector('#lst-ib') //#lst-ib is the ID of Google's search bar
test.value = 'abcd'
test.select()
window.getSelection().toString() //expected return value of 'abcd'
If I run this test in Chrome or Safari, I get the expected return value of 'abcd' - meaning the text in the input has been selected.
In FireFox, I get an empty string.
Does anyone have an explanation? I get the same behavior when I run this code on my own page from a script - not the console.
I'm testing on Firefox 54.01 and Chrome 59.0.3071.115
This is a known bug for Firefox. 16 years and counting.
https://bugzilla.mozilla.org/show_bug.cgi?id=85686

# Symbol In Object Key Name Only Works In Chrome?

ctv.currentdate = new Date(ctv["current"]["#attributes"].attr);
Page works like a charm in Chrome but Firefox, IE10, & Safari all don't work. Firefox console returns the following message:
TypeError: ctv.current['#attributes'] is undefined
If I do console.log(ctv["current"]["#attributes"]);, Firefox returns undefined whereas Chrome returns an actual value, ie. Object {attr: "2013-7-28"}.
Ideas?
Chrome is supporting "#", but that's technically not allowed in ES5. Nice read: http://mathiasbynens.be/notes/javascript-identifiers
Cool validator (if you want to explore further): http://mothereff.in/js-variables

Unexpected call to method or property access in IE 7

For work, I need to get our site working in IE7. Because, as we all know, the corporate world can't upgrade.
I am using IE8's IE7 emulation mode to test the site, and using IE8's wonderful debugger has been a nightmare.
My most recent problem is the following error:
Unexpected call to method or property access. jquery.js, line 113 character 460
I've put console.log commands on every line of my function, and figured out the line that's causing the error.
var $loading = $('<span/>').addClass('span-icon icon-ajax-loader').html('Loading...');
This line works fine in Firefox and Chrome. Oh, and it works fine when entering it into IE8's JavaScript console.
Why would this line give Unexpected call to method or property access? I think the call to the method or property was totally expected.
UPDATE: As per #Pointy's suggestion I broke that line into 3 lines.
var $loading = $('<span/>');
$loading.addClass('span-icon icon-ajax-loader');
$loading.html('Loading...');
Now I'm getting the error on this call $loading.html('Loading...');. Again, if I paste this code into IE8's developer tools and run it, it works fine.
Where are you injecting the content? Have you looked at this question and answer?
Javascript IE error: unexpected call to method or property access
Thanks to #daniellmb and #yoavmatchulsky for helping me fix this issue.
There are actually 3 separate solutions.
Use .text() instead of .html().
var $loading = $('<span/>').addClass('span-icon icon-ajax-loader').text('Loading...');
Wrap the .html() in span tags.
var $loading = $('<span/>').addClass('span-icon icon-ajax-loader').html('<span>Loading...</span>');
Or replace $('<span/>') with $('<span></span>').
var $loading = $('<span></span>').addClass('span-icon icon-ajax-loader').html('Loading...');

Javascript error in IE8: Not implemented

This one really puzzles me, as the code looks completely harmless.
IE8 halts script execution with a message:
Not implemented. map.js line:66 char:5
Here is a snip from the code:
63 if(data.map[x] !== undefined && data.map[x][y] !== undefined) {
64
65 left = (x - data.dim.x_min)*32 + 30;
66 top = (data.dim.y_max - y)*32 + 30;
67
68 /* do stuff */
XX }
debug info: x:263 data.dim.x_min:263 y:172 data.dim.y_max:174
Data is object returned from JQuery Ajax call. This works in Firefox 3.0 and 3.5, safari 4.0.2 and I've only found this error when viewing the page in IE8. Forcing IE8 into IE7 mode does not make the error go away.
I don't have IE7 to debug with, but I got a tester saying that it doesn't work in IE7 either.
The variable 'top' used in the code is an object of type DispHTMLWindow2 (outermost window object) and already in use by the browsers and that is causing the conflict, as that object cant be the target of the assignment operation. It seems that Firefox and Safari ignore this, while IE does not allow scripts to overwrite this.
Solutions for this:
1) Declare top you are using as local variable to define it's scope where it is used.
2) Rename the variable to something that doesn't conflict with this predefined global.
Description of other variable names you shouldn't use
IE 8 has a great javascript debugger. You might want to add a breakpoint somewhere before the error and step through the code to see if something is strange with the data. IE8 is picky with trailing commas in lists which might be why you only get the error in it. You can pull the debugger up with F12, click Script and choose start debugging. You can add a break point by clicking on the margin where the line numbers are.

Categories

Resources