Need a javascript solution to completely hide a portion of code in different screen devices












0















I'm trying to inegrate this javascript section with the correct width on mobile, desktop and tablet, so i wrote this:



this appears on mobile (using @media (min-width:...) in css)



<p align="center">News<script language="JavaScript" type="text/javascript" charset="iso-8859-1" src="//www.intopic.it/iframe.php?cat=fonti-rinnovabili&amp;rootcat=tecnologia&amp;type=2&amp;bgcolor=FFFFFF&amp;bdcolor=FFFFFF&amp;lcolor=666666&amp;font=1&amp;fontsize=13&amp;box=1050&amp;window=1"></script></p>


this appears on tablet (using @media (min-width:...) in css)



<p align="center">News<script language="JavaScript" type="text/javascript" charset="iso-8859-1" src="//www.intopic.it/iframe.php?cat=fonti-rinnovabili&amp;rootcat=tecnologia&amp;type=2&amp;bgcolor=FFFFFF&amp;bdcolor=FFFFFF&amp;lcolor=666666&amp;font=1&amp;fontsize=13&amp;box=1050&amp;window=1"></script></p>


this appears on desktop (using @media (min-width:...) in css)



<p align="center">News<script language="JavaScript" type="text/javascript" charset="iso-8859-1" src="//www.intopic.it/iframe.php?cat=fonti-rinnovabili&amp;rootcat=tecnologia&amp;type=2&amp;bgcolor=FFFFFF&amp;bdcolor=FFFFFF&amp;lcolor=666666&amp;font=1&amp;fontsize=13&amp;box=1050&amp;window=1"></script></p>


The problem is due to the variable "box" that is actually read 3 times by the browser, as each portion of code for mobile, tablet and pc are present and readable by the browser, it gets the last box value wich sets the width to 250 that is ok for mobile, but not for desktop and tablet, so i need something to show the only portion of code that fits the device every time dynamically, how can i do ?










share|improve this question


















  • 2





    so just document.write out the script tag after reading the page size

    – epascarello
    Nov 19 '18 at 14:46













  • I'm not sure I understand; those three snippets appear to be identical. Are you including all three in the same document? Why not just resize/style the same p in the css according to the min-width?

    – dgeare
    Nov 19 '18 at 14:50











  • Please provide full media queries. Avoid using javascript when not necessary.

    – Edwin Dijas Chiwona
    Nov 19 '18 at 14:56






  • 2





    Add max-width to your media queries.

    – nvioli
    Nov 19 '18 at 15:03











  • how can i document.write out() the code if the src it is an attribute of the <script> tag ?

    – Mxmx88
    Nov 19 '18 at 16:43
















0















I'm trying to inegrate this javascript section with the correct width on mobile, desktop and tablet, so i wrote this:



this appears on mobile (using @media (min-width:...) in css)



<p align="center">News<script language="JavaScript" type="text/javascript" charset="iso-8859-1" src="//www.intopic.it/iframe.php?cat=fonti-rinnovabili&amp;rootcat=tecnologia&amp;type=2&amp;bgcolor=FFFFFF&amp;bdcolor=FFFFFF&amp;lcolor=666666&amp;font=1&amp;fontsize=13&amp;box=1050&amp;window=1"></script></p>


this appears on tablet (using @media (min-width:...) in css)



<p align="center">News<script language="JavaScript" type="text/javascript" charset="iso-8859-1" src="//www.intopic.it/iframe.php?cat=fonti-rinnovabili&amp;rootcat=tecnologia&amp;type=2&amp;bgcolor=FFFFFF&amp;bdcolor=FFFFFF&amp;lcolor=666666&amp;font=1&amp;fontsize=13&amp;box=1050&amp;window=1"></script></p>


this appears on desktop (using @media (min-width:...) in css)



<p align="center">News<script language="JavaScript" type="text/javascript" charset="iso-8859-1" src="//www.intopic.it/iframe.php?cat=fonti-rinnovabili&amp;rootcat=tecnologia&amp;type=2&amp;bgcolor=FFFFFF&amp;bdcolor=FFFFFF&amp;lcolor=666666&amp;font=1&amp;fontsize=13&amp;box=1050&amp;window=1"></script></p>


The problem is due to the variable "box" that is actually read 3 times by the browser, as each portion of code for mobile, tablet and pc are present and readable by the browser, it gets the last box value wich sets the width to 250 that is ok for mobile, but not for desktop and tablet, so i need something to show the only portion of code that fits the device every time dynamically, how can i do ?










share|improve this question


















  • 2





    so just document.write out the script tag after reading the page size

    – epascarello
    Nov 19 '18 at 14:46













  • I'm not sure I understand; those three snippets appear to be identical. Are you including all three in the same document? Why not just resize/style the same p in the css according to the min-width?

    – dgeare
    Nov 19 '18 at 14:50











  • Please provide full media queries. Avoid using javascript when not necessary.

    – Edwin Dijas Chiwona
    Nov 19 '18 at 14:56






  • 2





    Add max-width to your media queries.

    – nvioli
    Nov 19 '18 at 15:03











  • how can i document.write out() the code if the src it is an attribute of the <script> tag ?

    – Mxmx88
    Nov 19 '18 at 16:43














0












0








0








I'm trying to inegrate this javascript section with the correct width on mobile, desktop and tablet, so i wrote this:



this appears on mobile (using @media (min-width:...) in css)



<p align="center">News<script language="JavaScript" type="text/javascript" charset="iso-8859-1" src="//www.intopic.it/iframe.php?cat=fonti-rinnovabili&amp;rootcat=tecnologia&amp;type=2&amp;bgcolor=FFFFFF&amp;bdcolor=FFFFFF&amp;lcolor=666666&amp;font=1&amp;fontsize=13&amp;box=1050&amp;window=1"></script></p>


this appears on tablet (using @media (min-width:...) in css)



<p align="center">News<script language="JavaScript" type="text/javascript" charset="iso-8859-1" src="//www.intopic.it/iframe.php?cat=fonti-rinnovabili&amp;rootcat=tecnologia&amp;type=2&amp;bgcolor=FFFFFF&amp;bdcolor=FFFFFF&amp;lcolor=666666&amp;font=1&amp;fontsize=13&amp;box=1050&amp;window=1"></script></p>


this appears on desktop (using @media (min-width:...) in css)



<p align="center">News<script language="JavaScript" type="text/javascript" charset="iso-8859-1" src="//www.intopic.it/iframe.php?cat=fonti-rinnovabili&amp;rootcat=tecnologia&amp;type=2&amp;bgcolor=FFFFFF&amp;bdcolor=FFFFFF&amp;lcolor=666666&amp;font=1&amp;fontsize=13&amp;box=1050&amp;window=1"></script></p>


The problem is due to the variable "box" that is actually read 3 times by the browser, as each portion of code for mobile, tablet and pc are present and readable by the browser, it gets the last box value wich sets the width to 250 that is ok for mobile, but not for desktop and tablet, so i need something to show the only portion of code that fits the device every time dynamically, how can i do ?










share|improve this question














I'm trying to inegrate this javascript section with the correct width on mobile, desktop and tablet, so i wrote this:



this appears on mobile (using @media (min-width:...) in css)



<p align="center">News<script language="JavaScript" type="text/javascript" charset="iso-8859-1" src="//www.intopic.it/iframe.php?cat=fonti-rinnovabili&amp;rootcat=tecnologia&amp;type=2&amp;bgcolor=FFFFFF&amp;bdcolor=FFFFFF&amp;lcolor=666666&amp;font=1&amp;fontsize=13&amp;box=1050&amp;window=1"></script></p>


this appears on tablet (using @media (min-width:...) in css)



<p align="center">News<script language="JavaScript" type="text/javascript" charset="iso-8859-1" src="//www.intopic.it/iframe.php?cat=fonti-rinnovabili&amp;rootcat=tecnologia&amp;type=2&amp;bgcolor=FFFFFF&amp;bdcolor=FFFFFF&amp;lcolor=666666&amp;font=1&amp;fontsize=13&amp;box=1050&amp;window=1"></script></p>


this appears on desktop (using @media (min-width:...) in css)



<p align="center">News<script language="JavaScript" type="text/javascript" charset="iso-8859-1" src="//www.intopic.it/iframe.php?cat=fonti-rinnovabili&amp;rootcat=tecnologia&amp;type=2&amp;bgcolor=FFFFFF&amp;bdcolor=FFFFFF&amp;lcolor=666666&amp;font=1&amp;fontsize=13&amp;box=1050&amp;window=1"></script></p>


The problem is due to the variable "box" that is actually read 3 times by the browser, as each portion of code for mobile, tablet and pc are present and readable by the browser, it gets the last box value wich sets the width to 250 that is ok for mobile, but not for desktop and tablet, so i need something to show the only portion of code that fits the device every time dynamically, how can i do ?







javascript html device-orientation cross-device






share|improve this question













share|improve this question











share|improve this question




share|improve this question










asked Nov 19 '18 at 14:41









Mxmx88Mxmx88

113




113








  • 2





    so just document.write out the script tag after reading the page size

    – epascarello
    Nov 19 '18 at 14:46













  • I'm not sure I understand; those three snippets appear to be identical. Are you including all three in the same document? Why not just resize/style the same p in the css according to the min-width?

    – dgeare
    Nov 19 '18 at 14:50











  • Please provide full media queries. Avoid using javascript when not necessary.

    – Edwin Dijas Chiwona
    Nov 19 '18 at 14:56






  • 2





    Add max-width to your media queries.

    – nvioli
    Nov 19 '18 at 15:03











  • how can i document.write out() the code if the src it is an attribute of the <script> tag ?

    – Mxmx88
    Nov 19 '18 at 16:43














  • 2





    so just document.write out the script tag after reading the page size

    – epascarello
    Nov 19 '18 at 14:46













  • I'm not sure I understand; those three snippets appear to be identical. Are you including all three in the same document? Why not just resize/style the same p in the css according to the min-width?

    – dgeare
    Nov 19 '18 at 14:50











  • Please provide full media queries. Avoid using javascript when not necessary.

    – Edwin Dijas Chiwona
    Nov 19 '18 at 14:56






  • 2





    Add max-width to your media queries.

    – nvioli
    Nov 19 '18 at 15:03











  • how can i document.write out() the code if the src it is an attribute of the <script> tag ?

    – Mxmx88
    Nov 19 '18 at 16:43








2




2





so just document.write out the script tag after reading the page size

– epascarello
Nov 19 '18 at 14:46







so just document.write out the script tag after reading the page size

– epascarello
Nov 19 '18 at 14:46















I'm not sure I understand; those three snippets appear to be identical. Are you including all three in the same document? Why not just resize/style the same p in the css according to the min-width?

– dgeare
Nov 19 '18 at 14:50





I'm not sure I understand; those three snippets appear to be identical. Are you including all three in the same document? Why not just resize/style the same p in the css according to the min-width?

– dgeare
Nov 19 '18 at 14:50













Please provide full media queries. Avoid using javascript when not necessary.

– Edwin Dijas Chiwona
Nov 19 '18 at 14:56





Please provide full media queries. Avoid using javascript when not necessary.

– Edwin Dijas Chiwona
Nov 19 '18 at 14:56




2




2





Add max-width to your media queries.

– nvioli
Nov 19 '18 at 15:03





Add max-width to your media queries.

– nvioli
Nov 19 '18 at 15:03













how can i document.write out() the code if the src it is an attribute of the <script> tag ?

– Mxmx88
Nov 19 '18 at 16:43





how can i document.write out() the code if the src it is an attribute of the <script> tag ?

– Mxmx88
Nov 19 '18 at 16:43












2 Answers
2






active

oldest

votes


















1














I Solved Writing This:






<script type="text/javascript">
if(window.innerWidth>1024){
document.write('x3Cscript language="JavaScript" type="text/javascript" charset="iso-8859-1" src="//www.intopic.it/iframe.php?cat=fonti-rinnovabili&amp;rootcat=tecnologia&amp;type=2&amp;bgcolor=FFFFFF&amp;bdcolor=FFFFFF&amp;lcolor=666666&amp;font=1&amp;fontsize=13&amp;box=1024&amp;window=1"x3C/script>');
}else if(window.innerWidth>600){document.write('x3Cscript language="JavaScript" type="text/javascript" charset="iso-8859-1" src="//www.intopic.it/iframe.php?cat=fonti-rinnovabili&amp;rootcat=tecnologia&amp;type=2&amp;bgcolor=FFFFFF&amp;bdcolor=FFFFFF&amp;lcolor=666666&amp;font=1&amp;fontsize=13&amp;box=600&amp;window=1"x3C/script>');}
else{
document.write('x3Cscript language="JavaScript" type="text/javascript" charset="iso-8859-1" src="//www.intopic.it/iframe.php?cat=fonti-rinnovabili&amp;rootcat=tecnologia&amp;type=2&amp;bgcolor=FFFFFF&amp;bdcolor=FFFFFF&amp;lcolor=666666&amp;font=1&amp;fontsize=13&amp;box=250&amp;window=1"x3C/script>');}
</script>








share|improve this answer


























  • Partially solved, now anything is visible below this piece of code, I think there's something inside the document.write() expressions that if executed, it prevents the rest of the code to be displayed, if i write a simple <h1>hello</h1> inside that document.write(), everything works fine....

    – Mxmx88
    Nov 20 '18 at 9:10





















0














Try:



var source_url, 
script_element = document.createElement("script");

if(window.innerWidth > 1024) {
script_element.src = "1024_script_source_url";
console.log('loaded 1024 url, window width', window.innerWidth);
} else if (window.innerWidth > 600) {
script_element.src = "600_script_source_url";
console.log('loaded 1024 url, window width', window.innerWidth);
}

document.head.append(script_element);

alert('done, window width' + window.innerWidth);


You'll probably want to subscribe to window resize event so...



window.onresize = function(event) {
//do something
};





share|improve this answer
























  • why do you declare var source_url ?

    – Mxmx88
    Nov 19 '18 at 16:21











Your Answer






StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");

StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});

function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});


}
});














draft saved

draft discarded


















StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53376983%2fneed-a-javascript-solution-to-completely-hide-a-portion-of-code-in-different-scr%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown

























2 Answers
2






active

oldest

votes








2 Answers
2






active

oldest

votes









active

oldest

votes






active

oldest

votes









1














I Solved Writing This:






<script type="text/javascript">
if(window.innerWidth>1024){
document.write('x3Cscript language="JavaScript" type="text/javascript" charset="iso-8859-1" src="//www.intopic.it/iframe.php?cat=fonti-rinnovabili&amp;rootcat=tecnologia&amp;type=2&amp;bgcolor=FFFFFF&amp;bdcolor=FFFFFF&amp;lcolor=666666&amp;font=1&amp;fontsize=13&amp;box=1024&amp;window=1"x3C/script>');
}else if(window.innerWidth>600){document.write('x3Cscript language="JavaScript" type="text/javascript" charset="iso-8859-1" src="//www.intopic.it/iframe.php?cat=fonti-rinnovabili&amp;rootcat=tecnologia&amp;type=2&amp;bgcolor=FFFFFF&amp;bdcolor=FFFFFF&amp;lcolor=666666&amp;font=1&amp;fontsize=13&amp;box=600&amp;window=1"x3C/script>');}
else{
document.write('x3Cscript language="JavaScript" type="text/javascript" charset="iso-8859-1" src="//www.intopic.it/iframe.php?cat=fonti-rinnovabili&amp;rootcat=tecnologia&amp;type=2&amp;bgcolor=FFFFFF&amp;bdcolor=FFFFFF&amp;lcolor=666666&amp;font=1&amp;fontsize=13&amp;box=250&amp;window=1"x3C/script>');}
</script>








share|improve this answer


























  • Partially solved, now anything is visible below this piece of code, I think there's something inside the document.write() expressions that if executed, it prevents the rest of the code to be displayed, if i write a simple <h1>hello</h1> inside that document.write(), everything works fine....

    – Mxmx88
    Nov 20 '18 at 9:10


















1














I Solved Writing This:






<script type="text/javascript">
if(window.innerWidth>1024){
document.write('x3Cscript language="JavaScript" type="text/javascript" charset="iso-8859-1" src="//www.intopic.it/iframe.php?cat=fonti-rinnovabili&amp;rootcat=tecnologia&amp;type=2&amp;bgcolor=FFFFFF&amp;bdcolor=FFFFFF&amp;lcolor=666666&amp;font=1&amp;fontsize=13&amp;box=1024&amp;window=1"x3C/script>');
}else if(window.innerWidth>600){document.write('x3Cscript language="JavaScript" type="text/javascript" charset="iso-8859-1" src="//www.intopic.it/iframe.php?cat=fonti-rinnovabili&amp;rootcat=tecnologia&amp;type=2&amp;bgcolor=FFFFFF&amp;bdcolor=FFFFFF&amp;lcolor=666666&amp;font=1&amp;fontsize=13&amp;box=600&amp;window=1"x3C/script>');}
else{
document.write('x3Cscript language="JavaScript" type="text/javascript" charset="iso-8859-1" src="//www.intopic.it/iframe.php?cat=fonti-rinnovabili&amp;rootcat=tecnologia&amp;type=2&amp;bgcolor=FFFFFF&amp;bdcolor=FFFFFF&amp;lcolor=666666&amp;font=1&amp;fontsize=13&amp;box=250&amp;window=1"x3C/script>');}
</script>








share|improve this answer


























  • Partially solved, now anything is visible below this piece of code, I think there's something inside the document.write() expressions that if executed, it prevents the rest of the code to be displayed, if i write a simple <h1>hello</h1> inside that document.write(), everything works fine....

    – Mxmx88
    Nov 20 '18 at 9:10
















1












1








1







I Solved Writing This:






<script type="text/javascript">
if(window.innerWidth>1024){
document.write('x3Cscript language="JavaScript" type="text/javascript" charset="iso-8859-1" src="//www.intopic.it/iframe.php?cat=fonti-rinnovabili&amp;rootcat=tecnologia&amp;type=2&amp;bgcolor=FFFFFF&amp;bdcolor=FFFFFF&amp;lcolor=666666&amp;font=1&amp;fontsize=13&amp;box=1024&amp;window=1"x3C/script>');
}else if(window.innerWidth>600){document.write('x3Cscript language="JavaScript" type="text/javascript" charset="iso-8859-1" src="//www.intopic.it/iframe.php?cat=fonti-rinnovabili&amp;rootcat=tecnologia&amp;type=2&amp;bgcolor=FFFFFF&amp;bdcolor=FFFFFF&amp;lcolor=666666&amp;font=1&amp;fontsize=13&amp;box=600&amp;window=1"x3C/script>');}
else{
document.write('x3Cscript language="JavaScript" type="text/javascript" charset="iso-8859-1" src="//www.intopic.it/iframe.php?cat=fonti-rinnovabili&amp;rootcat=tecnologia&amp;type=2&amp;bgcolor=FFFFFF&amp;bdcolor=FFFFFF&amp;lcolor=666666&amp;font=1&amp;fontsize=13&amp;box=250&amp;window=1"x3C/script>');}
</script>








share|improve this answer















I Solved Writing This:






<script type="text/javascript">
if(window.innerWidth>1024){
document.write('x3Cscript language="JavaScript" type="text/javascript" charset="iso-8859-1" src="//www.intopic.it/iframe.php?cat=fonti-rinnovabili&amp;rootcat=tecnologia&amp;type=2&amp;bgcolor=FFFFFF&amp;bdcolor=FFFFFF&amp;lcolor=666666&amp;font=1&amp;fontsize=13&amp;box=1024&amp;window=1"x3C/script>');
}else if(window.innerWidth>600){document.write('x3Cscript language="JavaScript" type="text/javascript" charset="iso-8859-1" src="//www.intopic.it/iframe.php?cat=fonti-rinnovabili&amp;rootcat=tecnologia&amp;type=2&amp;bgcolor=FFFFFF&amp;bdcolor=FFFFFF&amp;lcolor=666666&amp;font=1&amp;fontsize=13&amp;box=600&amp;window=1"x3C/script>');}
else{
document.write('x3Cscript language="JavaScript" type="text/javascript" charset="iso-8859-1" src="//www.intopic.it/iframe.php?cat=fonti-rinnovabili&amp;rootcat=tecnologia&amp;type=2&amp;bgcolor=FFFFFF&amp;bdcolor=FFFFFF&amp;lcolor=666666&amp;font=1&amp;fontsize=13&amp;box=250&amp;window=1"x3C/script>');}
</script>








<script type="text/javascript">
if(window.innerWidth>1024){
document.write('x3Cscript language="JavaScript" type="text/javascript" charset="iso-8859-1" src="//www.intopic.it/iframe.php?cat=fonti-rinnovabili&amp;rootcat=tecnologia&amp;type=2&amp;bgcolor=FFFFFF&amp;bdcolor=FFFFFF&amp;lcolor=666666&amp;font=1&amp;fontsize=13&amp;box=1024&amp;window=1"x3C/script>');
}else if(window.innerWidth>600){document.write('x3Cscript language="JavaScript" type="text/javascript" charset="iso-8859-1" src="//www.intopic.it/iframe.php?cat=fonti-rinnovabili&amp;rootcat=tecnologia&amp;type=2&amp;bgcolor=FFFFFF&amp;bdcolor=FFFFFF&amp;lcolor=666666&amp;font=1&amp;fontsize=13&amp;box=600&amp;window=1"x3C/script>');}
else{
document.write('x3Cscript language="JavaScript" type="text/javascript" charset="iso-8859-1" src="//www.intopic.it/iframe.php?cat=fonti-rinnovabili&amp;rootcat=tecnologia&amp;type=2&amp;bgcolor=FFFFFF&amp;bdcolor=FFFFFF&amp;lcolor=666666&amp;font=1&amp;fontsize=13&amp;box=250&amp;window=1"x3C/script>');}
</script>





<script type="text/javascript">
if(window.innerWidth>1024){
document.write('x3Cscript language="JavaScript" type="text/javascript" charset="iso-8859-1" src="//www.intopic.it/iframe.php?cat=fonti-rinnovabili&amp;rootcat=tecnologia&amp;type=2&amp;bgcolor=FFFFFF&amp;bdcolor=FFFFFF&amp;lcolor=666666&amp;font=1&amp;fontsize=13&amp;box=1024&amp;window=1"x3C/script>');
}else if(window.innerWidth>600){document.write('x3Cscript language="JavaScript" type="text/javascript" charset="iso-8859-1" src="//www.intopic.it/iframe.php?cat=fonti-rinnovabili&amp;rootcat=tecnologia&amp;type=2&amp;bgcolor=FFFFFF&amp;bdcolor=FFFFFF&amp;lcolor=666666&amp;font=1&amp;fontsize=13&amp;box=600&amp;window=1"x3C/script>');}
else{
document.write('x3Cscript language="JavaScript" type="text/javascript" charset="iso-8859-1" src="//www.intopic.it/iframe.php?cat=fonti-rinnovabili&amp;rootcat=tecnologia&amp;type=2&amp;bgcolor=FFFFFF&amp;bdcolor=FFFFFF&amp;lcolor=666666&amp;font=1&amp;fontsize=13&amp;box=250&amp;window=1"x3C/script>');}
</script>






share|improve this answer














share|improve this answer



share|improve this answer








edited Nov 20 '18 at 9:16

























answered Nov 19 '18 at 17:56









Mxmx88Mxmx88

113




113













  • Partially solved, now anything is visible below this piece of code, I think there's something inside the document.write() expressions that if executed, it prevents the rest of the code to be displayed, if i write a simple <h1>hello</h1> inside that document.write(), everything works fine....

    – Mxmx88
    Nov 20 '18 at 9:10





















  • Partially solved, now anything is visible below this piece of code, I think there's something inside the document.write() expressions that if executed, it prevents the rest of the code to be displayed, if i write a simple <h1>hello</h1> inside that document.write(), everything works fine....

    – Mxmx88
    Nov 20 '18 at 9:10



















Partially solved, now anything is visible below this piece of code, I think there's something inside the document.write() expressions that if executed, it prevents the rest of the code to be displayed, if i write a simple <h1>hello</h1> inside that document.write(), everything works fine....

– Mxmx88
Nov 20 '18 at 9:10







Partially solved, now anything is visible below this piece of code, I think there's something inside the document.write() expressions that if executed, it prevents the rest of the code to be displayed, if i write a simple <h1>hello</h1> inside that document.write(), everything works fine....

– Mxmx88
Nov 20 '18 at 9:10















0














Try:



var source_url, 
script_element = document.createElement("script");

if(window.innerWidth > 1024) {
script_element.src = "1024_script_source_url";
console.log('loaded 1024 url, window width', window.innerWidth);
} else if (window.innerWidth > 600) {
script_element.src = "600_script_source_url";
console.log('loaded 1024 url, window width', window.innerWidth);
}

document.head.append(script_element);

alert('done, window width' + window.innerWidth);


You'll probably want to subscribe to window resize event so...



window.onresize = function(event) {
//do something
};





share|improve this answer
























  • why do you declare var source_url ?

    – Mxmx88
    Nov 19 '18 at 16:21
















0














Try:



var source_url, 
script_element = document.createElement("script");

if(window.innerWidth > 1024) {
script_element.src = "1024_script_source_url";
console.log('loaded 1024 url, window width', window.innerWidth);
} else if (window.innerWidth > 600) {
script_element.src = "600_script_source_url";
console.log('loaded 1024 url, window width', window.innerWidth);
}

document.head.append(script_element);

alert('done, window width' + window.innerWidth);


You'll probably want to subscribe to window resize event so...



window.onresize = function(event) {
//do something
};





share|improve this answer
























  • why do you declare var source_url ?

    – Mxmx88
    Nov 19 '18 at 16:21














0












0








0







Try:



var source_url, 
script_element = document.createElement("script");

if(window.innerWidth > 1024) {
script_element.src = "1024_script_source_url";
console.log('loaded 1024 url, window width', window.innerWidth);
} else if (window.innerWidth > 600) {
script_element.src = "600_script_source_url";
console.log('loaded 1024 url, window width', window.innerWidth);
}

document.head.append(script_element);

alert('done, window width' + window.innerWidth);


You'll probably want to subscribe to window resize event so...



window.onresize = function(event) {
//do something
};





share|improve this answer













Try:



var source_url, 
script_element = document.createElement("script");

if(window.innerWidth > 1024) {
script_element.src = "1024_script_source_url";
console.log('loaded 1024 url, window width', window.innerWidth);
} else if (window.innerWidth > 600) {
script_element.src = "600_script_source_url";
console.log('loaded 1024 url, window width', window.innerWidth);
}

document.head.append(script_element);

alert('done, window width' + window.innerWidth);


You'll probably want to subscribe to window resize event so...



window.onresize = function(event) {
//do something
};






share|improve this answer












share|improve this answer



share|improve this answer










answered Nov 19 '18 at 15:01









Tom StTom St

577511




577511













  • why do you declare var source_url ?

    – Mxmx88
    Nov 19 '18 at 16:21



















  • why do you declare var source_url ?

    – Mxmx88
    Nov 19 '18 at 16:21

















why do you declare var source_url ?

– Mxmx88
Nov 19 '18 at 16:21





why do you declare var source_url ?

– Mxmx88
Nov 19 '18 at 16:21


















draft saved

draft discarded




















































Thanks for contributing an answer to Stack Overflow!


  • Please be sure to answer the question. Provide details and share your research!

But avoid



  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.


To learn more, see our tips on writing great answers.




draft saved


draft discarded














StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53376983%2fneed-a-javascript-solution-to-completely-hide-a-portion-of-code-in-different-scr%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown





















































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown

































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown







Popular posts from this blog

鏡平學校

ꓛꓣだゔៀៅຸ໢ທຮ໕໒ ,ໂ'໥໓າ໼ឨឲ៵៭ៈゎゔit''䖳𥁄卿' ☨₤₨こゎもょの;ꜹꟚꞖꞵꟅꞛေၦေɯ,ɨɡ𛃵𛁹ޝ޳ޠ޾,ޤޒޯ޾𫝒𫠁သ𛅤チョ'サノބޘދ𛁐ᶿᶇᶀᶋᶠ㨑㽹⻮ꧬ꧹؍۩وَؠ㇕㇃㇪ ㇦㇋㇋ṜẰᵡᴠ 軌ᵕ搜۳ٰޗޮ޷ސޯ𫖾𫅀ल, ꙭ꙰ꚅꙁꚊꞻꝔ꟠Ꝭㄤﺟޱސꧨꧼ꧴ꧯꧽ꧲ꧯ'⽹⽭⾁⿞⼳⽋២៩ញណើꩯꩤ꩸ꩮᶻᶺᶧᶂ𫳲𫪭𬸄𫵰𬖩𬫣𬊉ၲ𛅬㕦䬺𫝌𫝼,,𫟖𫞽ហៅ஫㆔ాఆఅꙒꚞꙍ,Ꙟ꙱エ ,ポテ,フࢰࢯ𫟠𫞶 𫝤𫟠ﺕﹱﻜﻣ𪵕𪭸𪻆𪾩𫔷ġ,ŧآꞪ꟥,ꞔꝻ♚☹⛵𛀌ꬷꭞȄƁƪƬșƦǙǗdžƝǯǧⱦⱰꓕꓢႋ神 ဴ၀க௭எ௫ឫោ ' េㇷㇴㇼ神ㇸㇲㇽㇴㇼㇻㇸ'ㇸㇿㇸㇹㇰㆣꓚꓤ₡₧ ㄨㄟ㄂ㄖㄎ໗ツڒذ₶।ऩछएोञयूटक़कयँृी,冬'𛅢𛅥ㇱㇵㇶ𥄥𦒽𠣧𠊓𧢖𥞘𩔋цѰㄠſtʯʭɿʆʗʍʩɷɛ,əʏダヵㄐㄘR{gỚṖḺờṠṫảḙḭᴮᵏᴘᵀᵷᵕᴜᴏᵾq﮲ﲿﴽﭙ軌ﰬﶚﶧ﫲Ҝжюїкӈㇴffצּ﬘﭅﬈軌'ffistfflſtffतभफɳɰʊɲʎ𛁱𛁖𛁮𛀉 𛂯𛀞నఋŀŲ 𫟲𫠖𫞺ຆຆ ໹້໕໗ๆทԊꧢꧠ꧰ꓱ⿝⼑ŎḬẃẖỐẅ ,ờỰỈỗﮊDžȩꭏꭎꬻ꭮ꬿꭖꭥꭅ㇭神 ⾈ꓵꓑ⺄㄄ㄪㄙㄅㄇstA۵䞽ॶ𫞑𫝄㇉㇇゜軌𩜛𩳠Jﻺ‚Üမ႕ႌႊၐၸဓၞၞၡ៸wyvtᶎᶪᶹစဎ꣡꣰꣢꣤ٗ؋لㇳㇾㇻㇱ㆐㆔,,㆟Ⱶヤマފ޼ޝަݿݞݠݷݐ',ݘ,ݪݙݵ𬝉𬜁𫝨𫞘くせぉて¼óû×ó£…𛅑הㄙくԗԀ5606神45,神796'𪤻𫞧ꓐ㄁ㄘɥɺꓵꓲ3''7034׉ⱦⱠˆ“𫝋ȍ,ꩲ軌꩷ꩶꩧꩫఞ۔فڱێظペサ神ナᴦᵑ47 9238їﻂ䐊䔉㠸﬎ffiﬣ,לּᴷᴦᵛᵽ,ᴨᵤ ᵸᵥᴗᵈꚏꚉꚟ⻆rtǟƴ𬎎

Why https connections are so slow when debugging (stepping over) in Java?