Sunday, May 19, 2024
 Popular · Latest · Hot · Upcoming
153
rated 0 times [  157] [ 4]  / answers: 1 / hits: 23063  / 9 Years ago, sat, november 28, 2015, 12:00:00

This is my code. I'm trying to stop running an external js file when screen width is less than 1025.



<script type=text/javascript>
var gdsize = 1025;
if(window.innerWidth>=gdsize) {

<script>
window.cookieconsent_options = {message:Geek Dashboard uses cookies to make sure you get the best experience on our website. -,dismiss:It's OK,learnMore:More Details Here,link:http://www.geekdashboard.com/cookies/,theme:dark-bottom};
}
</script>


</script>

<script type=text/javascript src=//cdnjs.cloudflare.com/ajax/libs/cookieconsent2/1.0.9/cookieconsent.min.js></script>

More From » html

 Answers
8

Why would you use a nested script to modify an object property?



It can be solved in a much simpler way since you're already in the script:



<script type=text/javascript>
var gdsize = 1025;
if(window.innerWidth>=gdsize) {

window.cookieconsent_options = {message:Geek Dashboard uses cookies to make sure you get the best experience on our website. -,dismiss:It's OK,learnMore:More Details Here,link:http://www.geekdashboard.com/cookies/,theme:dark-bottom};

}
</script>

[#64244] Wednesday, November 25, 2015, 9 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
albert

Total Points: 652
Total Questions: 105
Total Answers: 108

Location: Pitcairn Islands
Member since Fri, Oct 15, 2021
3 Years ago
;