Closed cliffstudio closed 6 years ago
EDIT: Solved in the course of this discussion at jQuery forum - The bounty of €100 went to "jakecigar"
Is this happening within an inline script? If yes, my guess is:
Because it's occuring in a for loop, that you have a "less than sign" ("<") followed directly by an alpha-character. Please try adding a space between the "<" character and the letter. This is a known error in jQuery core, which I currently don't know how to fix. (I have worked around the same bug on 4nf.org, as described above)
For example, it might be worth trying to:
and then
Ah I see, thanks for getting back to me on this one...You can see the bug in question here: http://elliottdev.nealfletcher.co.uk
If you click on 'Studio' in the top right, you'll see the error in the console. Where would you suggest adding the space exactly?
Thanks for your swift reply and the link! Because I'm currently not at my own PC, I can't see the exact text of the error message. Please try adding the space directly after the "less than sign"...
Here - I think I've pinpointed it:
h<i.length;h++
Just add a space after the "less than sign"
I think I've got to the bottom of it – there was some inline script being added by Wordpress that contained a < sign, disabling this has fixed that issue :)
One small problem now though is that the URL doesn't seem to be updating on page change for some reason?
Glad we found the exact position of the error.
I just checked the console - very weird - no other errors...
Just another guess -> maybe Wordpress needs the inline script you disabled. Maybe the ideal solution is to really insert a space in the inline script instead. (You may be able to edit the PHP of the respective plugin in the WP-Admin)
Hmm I don't think so as the URL wasn't changing before this script was disabled. The script in question is the emojicon script that's added by default by WP to enable emojicons. Any other ideas?
Am thinking, but no other ideas at the moment... Might have a look at your HTML when I have the time...
One thing that came to my attention is that the canonical URL always seems to be:
<link rel="canonical" href="http://elliottdev.nealfletcher.co.uk">
...for both "Work" and "Studio"?
Ajaxify uses the canonical URL, when it is given...
EDIT: Forget about this last comment - it was because the page wasn't re-loading
Regarding a solution to the original problem - the "less than sign" that causes the inline script to crash - it would require, in a first step, to catch the error when appending the failing inline script.
I have tried various
try...catch
statements in different places, but they don't seem to prevent a "hard error" - in effect, they do nothing at all.
I believe, that would be the first step to combat the bug...
Here is the salient code explicitly:
addtext: function (t, type) { //Add one inline JS script - main function
if(!t || !t.length) return; //Ensure input
if(!type) type = 'text/javascript'; //Validate type
if(inlineappend || !type.iO('text/javascript')) try { return _apptext(t, type); } catch (e) { $.log("Error in apptext: " + t + "\nType: " + type + "\nCode: " + console.debug(e)); }
try { $.globalEval(t); } catch (e1) { //instead of appending, try an eval
try { eval(t); } catch (e2) {
$.log("Error in inline script : " + t + "\nError code : " + e2);
}
}
},
apptext: function (t, type) { //Append a single inline script to the main content div
var scriptNode = document.createElement('script'); //low-level assembly of script node
scriptNode.type = type;
scriptNode.appendChild(document.createTextNode(t));
try { cd0.appendChild(scriptNode); } catch (e) { $.log("Bad inline script text in apptext: " + t); }
},
Any ideas?
Fixed presumably! Therefore closing...
Summary: When encountering this bug, please edit the PHP of the plugin causing the error and insert a space after the "less than" sign or disable the respective plugin altogether.
After clicking on a page link I keep repeatedly getting the following error: SyntaxError: Unexpected identifier 'img'. Expected a ';' after the for loop condition expression.
This is preventing a change in the URL, it's highlighting this error in the title tag of the site, anyway not sure what's causing it, can provide a link if needs be? If anyone could shed any light that'd be great!