Home › Toolset Professional Support › [Resolved] Strange quotes in (Toolset?) javascript-code causes strange behavior
This is the technical support forum for Toolset - a suite of plugins for developing WordPress sites without writing PHP.
Everyone can read this forum, but only Toolset clients can post in it. Toolset support works 6 days per week, 19 hours per day.
Sun | Mon | Tue | Wed | Thu | Fri | Sat |
---|---|---|---|---|---|---|
- | 9:00 – 12:00 | 9:00 – 12:00 | 9:00 – 12:00 | 9:00 – 12:00 | 9:00 – 12:00 | - |
- | 13:00 – 18:00 | 13:00 – 18:00 | 13:00 – 18:00 | 14:00 – 18:00 | 13:00 – 18:00 | - |
Supporter timezone: America/Jamaica (GMT-05:00)
Tagged: Toolset Blocks
This topic contains 12 replies, has 3 voices.
Last updated by Shane 4 years, 2 months ago.
Assisted by: Shane.
Hi support!
Can you please confirm if this javascript code is generated by Toolset?
<script type="text/javascript">
const wpvViewHead = document.getElementsByTagName( "head" )[ 0 ];
const wpvViewExtraCss = document.createElement( "style" );
wpvViewExtraCss.textContent = `<!--[if IE 7]><style>
.wpv-pagination { *zoom: 1; }
</style><![endif]-->
`
wpvViewHead.appendChild( wpvViewExtraCss );
</script>
If 'yes', how can I disable this code or how can I change these quotes (``) to normal quotes ('')?
Here's the main problem: I use the plugin 'Custom CSS and JS PRO' to add scripts within the <head>-tags of my website. Strange enough, those code is put between the <body>-tags when I check it via Chrome's F12 webdeveloper console. When contacting their support, they told me that this is because of the upper pasted code.
Can you help me so I can get my Google Ad Manager pubs up and running please?
Kind regards,
Sam from Roularta
Languages: English (English ) Spanish (Español )
Timezone: Europe/London (GMT+00:00)
Which version of Blocks are you using?
That code is added by Toolset, it related to applying custom CSS styles on the front end.
Those "quotes" are backticks, and because of an unrelated compatibility issue with IE11 we stopped using them in Blocks 1.3.
So if you are using the current version you shouldn't be seeing those.
Hi Nigel,
I checked the plugins and saw that I haven't installed the 'Blocks'-plugin. See screenshot 'toolset-blocks.PNG'.
The support team of SilkyPress (creator of 'Custom CSS and JS PRO') updated their answer and said there's also an issue with the integration of that style in the console. It looks like there are <style></style>-tags within another <style></style>-tags. See screenshot 'double-style-tag.png'. Perhaps this is the daemon I am looking for? 🙂
Kind regards,
Sam from Roularta.
Languages: English (English ) Spanish (Español )
Timezone: Europe/London (GMT+00:00)
Hi Sam
You are using an old version of Views, though (they are essentially the same plugin).
Please update to the latest version of Views, it should resolve the problem.
Hi Sam,
As Nigel mentioned this issue is resolved with an update of views so you will need to download the latest version from the link below.
https://toolset.com/account/downloads/#legacy-plugins
Thanks,
Shane
Hi Nigel and Shane,
I've installed the Blocks-plugin, the Views-plugin is automatically disabled. It seems that the quotes are okay now, so that's a good thing!
But after SilkyPress updated their support answer, it seems that the double style-tag causes my scripts loading in the <body>-tag instead of between the <head>-tags. See Googles F12 and added screenshot.
Is there a quick fix to output this:
<!--[if IE 7]><style>.wpv-pagination { *zoom: 1; }</style><![endif]-->
instead of this:
<style><!--[if IE 7]><style>.wpv-pagination { *zoom: 1; }</style><![endif]--></style>
Thanks a lot!
Sam from Roularta
Hi Sam,
Happy to see the issue is partially resolved.
Regarding your script what exactly is it meant to do ? Can you send me a copy so that I can have a look?
Also are you using a plugin to insert the script onto the page if so can you let me know which one ?
Thanks,
Shane
Hi Shane,
I'm using 'Custom CSS and JS PRO' to add HTML to the head of my pages. Here's the script that should be pushed in the <head> of my 'projecten' page (hidden link):
<!-- Begin Google Ad Manager -->
<script async src="hidden link"></script>
<script>
window.googletag = window.googletag || {cmd: []};
/**
* Locatie ophalen.
* De locatie wordt uit de Toolset parameter 'toolset_maps_distance_center' gehaald.
* Mogelijke waardes van deze parameter: postcode, provincie, long & lat (indien het script om die waarde te interpreteren niet werkt).
*/
var currentUrlString = window.location.href;
var currentUrl = new URL(currentUrlString);
var currentLocation = currentUrl.searchParams.get('toolset_maps_distance_center');
console.log('toolset_maps_distance_center: ' + currentLocation);
// Hier nog checken of de toolset_maps_distance_center (currentLocation) bestaat
//var zipcode = 0;
getPubCodeByLocation(currentLocation, bannering);
function bannering(pubCode) {
console.log('Dit is de geretourneerde pubCode: ' + pubCode);
googletag.cmd.push(function () {
/** SizeMapping opzetten */
// BANNER
var mapping_BANNER = googletag.sizeMapping().addSize([320,0],
[[300,75]]).addSize([980,0],
[[980,150],[960,150],[970,250],[840,150],[840,250],[728,90]]).build();
/** Slots definiëren */
// BANNER_ABOVE_1
googletag.defineSlot('/21768925892/5860_I000/I0181', [],
'gpt-ad-BANNER_ABOVE_1')
.defineSizeMapping(mapping_BANNER)
.addService(googletag.pubads())
.setTargeting('AdType', ['BANNER_ABOVE']);
// BANNER_ABOVE_2
googletag.defineSlot('/21768925892/5860_I000/I0181', [],
'gpt-ad-BANNER_ABOVE_2')
.defineSizeMapping(mapping_BANNER)
.addService(googletag.pubads())
.setTargeting('AdType', ['BANNER_ABOVE']);
/** Request naar Google Ad Manager */
googletag.pubads().enableSingleRequest();
googletag.pubads().collapseEmptyDivs();
googletag.enableServices();
});
/**
* I0178 - Antwerpen
* I0179 - Limburg
* I0180 - Oost-Vlaanderen
* I0181 - West-Vlaanderen
* I0182 - Vlaams-Brabant
*/
}
function getPubCodeByLocation(location, func ) {
// API call voor ophalen van lat en lon
console.log('Ingegeven locatie: ' + location);
var xhttp = new XMLHttpRequest();
xhttp.onreadystatechange = function() {
if (this.readyState == 4 && this.status == 200) {
var jsonResponse = this.responseText;
jsonResponse = JSON.parse(jsonResponse); // JSON object van string maken
console.log(jsonResponse);
var zipcode = jsonResponse['0']['address']['postcode'];
var county = jsonResponse['0']['address']['county'];
console.log('Postcode: ' + zipcode);
console.log('Provincie: ' + county);
var pubCode = '';
switch(county) {
case 'West Flanders':
case 'West-Vlaanderen':
zipcode = 8000; // Brugge
pubCode = 'I0181';
break;
case 'East Flanders':
case 'Oost-Vlaanderen':
zipcode = 9000; // Gent
pubCode = 'I0180';
break;
case 'Antwerp':
case 'Antwerpen':
zipcode = 2000; // Antwerpen
pubCode = 'I0178';
break;
case 'Limburg':
zipcode = 3500; // Hasselt
pubCode = 'I0179';
break;
case 'Flemish Brabant': // Leuven
case 'Vlaams-Brabant':
zipcode = 3000;
pubCode = 'I0182';
break;
default:
zipcode = 1000; // Brussel
pubCode = 'I0182';
}
console.log('Te retourneren pubCode: ' + pubCode);
func(pubCode);
}
return pubCode;
};
xhttp.open(
'GET',
'hidden link' + location + '?format=json&addressdetails=1&limit=1',
true
);
xhttp.setRequestHeader('Content-type', 'application/json');
xhttp.send();
}
</script>
<!-- End Google Ad Manager -->
So the upper script is loaded between the <body>-tags instead of the <head>-tags where it should be. Custom CSS and JS PRO support told me that it's causes by the double <style><style></style></style> tags:
<style><!--[if IE 7]><style>.wpv-pagination { *zoom: 1; }</style><![endif]--></style>
Can this be fixed?
Or can we temporary remove that style code so I can do an additional test? We're not supporting IE7 anymore, so it's not that bad if the code doesn't exist anymore...
Hi Shane,
Sorry for being impatient. I hope to fix this as soon as possible because clients are paying for their ads without seeing them.
Can you give me a clue how to change that double <style> issue please?
Thanks! 🙂
Hi Roularta,
So I tried to replicate this issue on my end and it is appearing in the header for me, see screenshot.
Perhaps something else it at play here, can you send me a link to the page where I can see the issue itself ?
Thanks,
Shane
Hi Shane,
Friday, I had a day off so I couldn't check your latest reply. Here's a screenshot of my homepage with Chromes developer toolbar opened. As you can see, the code appears in the body tags. This screenshot shows the homepage. Same problem on the page 'Projecten'.
Kind regards,
Sam from Roularta
Hi Shane,
can we (temporary) remove that style code (see under) so I can do an additional test? We're not supporting IE7 anymore, so it's not that bad if the code doesn't exist anymore...
<style><!--[if IE 7]><style>.wpv-pagination { *zoom: 1; }</style><![endif]--></style>
I really need the issue to be solved now 🙁
Kind regards,
Sam from Roularta
Hi Sam,
Unfortunately no, there isn't a way to remove this one.
As mentioned this issue doesn't occur for me at all. Have you tried using any alternative plugins to insert the custom code on your site ?
https://wordpress.org/plugins/search/custom+css/
Please try one of the alternatives and let me know if the issue still remains.
Thanks,
Shane