How to load HTML file with style without affecting the rest of the page styles?2019 Community Moderator ElectionHow can I upload files asynchronously?Styling an input type=“file” buttonHow do I modify the URL without reloading the page?How do I include a JavaScript file in another JavaScript file?How to style a <select> dropdown with only CSS?How to create an HTML button that acts like a link?How to style a checkbox using CSS?How can I refresh a page with jQuery?Redirect from an HTML pageLoad a html page to a div without affecting the style outside the div

Is there a term for accumulated dirt on the outside of your hands and feet?

Hausdorff dimension of the boundary of fibres of Lipschitz maps

Is honey really a supersaturated solution? Does heating to un-crystalize redissolve it or melt it?

If "dar" means "to give", what does "daros" mean?

Suggestions on how to spend Shaabath (constructively) alone

Can a medieval gyroplane be built?

Recruiter wants very extensive technical details about all of my previous work

How do hiring committees for research positions view getting "scooped"?

Can other pieces capture a threatening piece and prevent a checkmate?

Is it insecure to send a password in a `curl` command?

Probably overheated black color SMD pads

Brake pads destroying wheels

What are substitutions for coconut in curry?

How to get the n-th line after a grepped one?

Does multi-classing into Fighter give you heavy armor proficiency?

Print last inputted byte

I seem to dance, I am not a dancer. Who am I?

Differential and Linear trail propagation in Noekeon

How to terminate ping <dest> &

Calculate the frequency of characters in a string

The average age of first marriage in Russia

My friend is being a hypocrite

Should I be concerned about student access to a test bank?

Practical application of matrices and determinants



How to load HTML file with style without affecting the rest of the page styles?



2019 Community Moderator ElectionHow can I upload files asynchronously?Styling an input type=“file” buttonHow do I modify the URL without reloading the page?How do I include a JavaScript file in another JavaScript file?How to style a <select> dropdown with only CSS?How to create an HTML button that acts like a link?How to style a checkbox using CSS?How can I refresh a page with jQuery?Redirect from an HTML pageLoad a html page to a div without affecting the style outside the div










0















I am creating a basic email client for myself in electron. When I load an email, that email data needs to be displayed inside a div element that looks like this <div id="emailDisplay"></div>. The only problem is that this html can contain embedded stylesheets which then affect the rest of the page. I tried using an iframe but when one of the elements failed to load (such as an image), it caused an exception and my other needed JavaScript is never executed. The exact error is net::ERR_CONNECTION_TIMED_OUT. So what I'm asking is how can I display this HTML without it affecting the rest of the document's styles or how can I catch and ignore the iframe error? Thanks in advance.










share|improve this question






















  • iframe is the way to go. The error is going to happen no matter what you use, since that's a network error and has nothing to do with code. You could try embed or object but those have the same issues as iframe and are harder to use.

    – Heretic Monkey
    Mar 6 at 22:27















0















I am creating a basic email client for myself in electron. When I load an email, that email data needs to be displayed inside a div element that looks like this <div id="emailDisplay"></div>. The only problem is that this html can contain embedded stylesheets which then affect the rest of the page. I tried using an iframe but when one of the elements failed to load (such as an image), it caused an exception and my other needed JavaScript is never executed. The exact error is net::ERR_CONNECTION_TIMED_OUT. So what I'm asking is how can I display this HTML without it affecting the rest of the document's styles or how can I catch and ignore the iframe error? Thanks in advance.










share|improve this question






















  • iframe is the way to go. The error is going to happen no matter what you use, since that's a network error and has nothing to do with code. You could try embed or object but those have the same issues as iframe and are harder to use.

    – Heretic Monkey
    Mar 6 at 22:27













0












0








0








I am creating a basic email client for myself in electron. When I load an email, that email data needs to be displayed inside a div element that looks like this <div id="emailDisplay"></div>. The only problem is that this html can contain embedded stylesheets which then affect the rest of the page. I tried using an iframe but when one of the elements failed to load (such as an image), it caused an exception and my other needed JavaScript is never executed. The exact error is net::ERR_CONNECTION_TIMED_OUT. So what I'm asking is how can I display this HTML without it affecting the rest of the document's styles or how can I catch and ignore the iframe error? Thanks in advance.










share|improve this question














I am creating a basic email client for myself in electron. When I load an email, that email data needs to be displayed inside a div element that looks like this <div id="emailDisplay"></div>. The only problem is that this html can contain embedded stylesheets which then affect the rest of the page. I tried using an iframe but when one of the elements failed to load (such as an image), it caused an exception and my other needed JavaScript is never executed. The exact error is net::ERR_CONNECTION_TIMED_OUT. So what I'm asking is how can I display this HTML without it affecting the rest of the document's styles or how can I catch and ignore the iframe error? Thanks in advance.







javascript html css node.js electron






share|improve this question













share|improve this question











share|improve this question




share|improve this question










asked Mar 6 at 22:04









JonahJonah

1113




1113












  • iframe is the way to go. The error is going to happen no matter what you use, since that's a network error and has nothing to do with code. You could try embed or object but those have the same issues as iframe and are harder to use.

    – Heretic Monkey
    Mar 6 at 22:27

















  • iframe is the way to go. The error is going to happen no matter what you use, since that's a network error and has nothing to do with code. You could try embed or object but those have the same issues as iframe and are harder to use.

    – Heretic Monkey
    Mar 6 at 22:27
















iframe is the way to go. The error is going to happen no matter what you use, since that's a network error and has nothing to do with code. You could try embed or object but those have the same issues as iframe and are harder to use.

– Heretic Monkey
Mar 6 at 22:27





iframe is the way to go. The error is going to happen no matter what you use, since that's a network error and has nothing to do with code. You could try embed or object but those have the same issues as iframe and are harder to use.

– Heretic Monkey
Mar 6 at 22:27












2 Answers
2






active

oldest

votes


















0














Well, what about using a tag within your HTML?
It would still being HTML and if you specify it to style just one tag it will work.



<div id="emailDisplay"></div>
<style>
#emailDisplay
background-color: red;

</style>


Another way of resolving this problem is by creating encapsulated javascript components (maybe with Vue or React)






share|improve this answer























  • The problem with this, is there is no way to pull the style tag from the document. I could use RegEx but the problem is I can't be 100% that it will get the style for every email.

    – Jonah
    Mar 6 at 22:16


















0














Only ancient email clients support running JavaScript, to do so opens so many security vulnerabilities, not advised. Iframe creates another browser context. Each browser context is a complete document environment, is not possible for the iframe CSS to affect the parent CSS.






share|improve this answer























  • Yes, I understand this but my JavaScript isn't loaded when the get request for my image isn't loaded.

    – Jonah
    Mar 6 at 22:22











  • Saying you need your code to run before your image is loaded? Move the code above the image, load JavaScript in the head of the document

    – Joshua Robinson
    Mar 6 at 22:24











  • The JavaScript is in the head.

    – Jonah
    Mar 6 at 22:31











  • Can simplified relevant code be added to the question? More than happy to help, confused about the part where an image failing to load throws a JavaScript error, unless there is an onLoad handler attached that’s has some buggy code

    – Joshua Robinson
    Mar 6 at 22:34











  • So I figured it out but I can't leave you hanging right because you'll go mad trying to understand. Basically, I had added a window.onload event at one point in my code and all my JavaScript was inside of this. So, while the image was waiting for the GET response, the JavaScript basically was unusable. So, I moved my JavaScript out of this window.onload and now it works perfectly because of this. Thank for being willing to help and if you wish to discuss this further, you can add me on discord Jonah#5945.

    – Jonah
    Mar 6 at 23:36










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%2f55032891%2fhow-to-load-html-file-with-style-without-affecting-the-rest-of-the-page-styles%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









0














Well, what about using a tag within your HTML?
It would still being HTML and if you specify it to style just one tag it will work.



<div id="emailDisplay"></div>
<style>
#emailDisplay
background-color: red;

</style>


Another way of resolving this problem is by creating encapsulated javascript components (maybe with Vue or React)






share|improve this answer























  • The problem with this, is there is no way to pull the style tag from the document. I could use RegEx but the problem is I can't be 100% that it will get the style for every email.

    – Jonah
    Mar 6 at 22:16















0














Well, what about using a tag within your HTML?
It would still being HTML and if you specify it to style just one tag it will work.



<div id="emailDisplay"></div>
<style>
#emailDisplay
background-color: red;

</style>


Another way of resolving this problem is by creating encapsulated javascript components (maybe with Vue or React)






share|improve this answer























  • The problem with this, is there is no way to pull the style tag from the document. I could use RegEx but the problem is I can't be 100% that it will get the style for every email.

    – Jonah
    Mar 6 at 22:16













0












0








0







Well, what about using a tag within your HTML?
It would still being HTML and if you specify it to style just one tag it will work.



<div id="emailDisplay"></div>
<style>
#emailDisplay
background-color: red;

</style>


Another way of resolving this problem is by creating encapsulated javascript components (maybe with Vue or React)






share|improve this answer













Well, what about using a tag within your HTML?
It would still being HTML and if you specify it to style just one tag it will work.



<div id="emailDisplay"></div>
<style>
#emailDisplay
background-color: red;

</style>


Another way of resolving this problem is by creating encapsulated javascript components (maybe with Vue or React)







share|improve this answer












share|improve this answer



share|improve this answer










answered Mar 6 at 22:12









Michel CalheirosMichel Calheiros

754




754












  • The problem with this, is there is no way to pull the style tag from the document. I could use RegEx but the problem is I can't be 100% that it will get the style for every email.

    – Jonah
    Mar 6 at 22:16

















  • The problem with this, is there is no way to pull the style tag from the document. I could use RegEx but the problem is I can't be 100% that it will get the style for every email.

    – Jonah
    Mar 6 at 22:16
















The problem with this, is there is no way to pull the style tag from the document. I could use RegEx but the problem is I can't be 100% that it will get the style for every email.

– Jonah
Mar 6 at 22:16





The problem with this, is there is no way to pull the style tag from the document. I could use RegEx but the problem is I can't be 100% that it will get the style for every email.

– Jonah
Mar 6 at 22:16













0














Only ancient email clients support running JavaScript, to do so opens so many security vulnerabilities, not advised. Iframe creates another browser context. Each browser context is a complete document environment, is not possible for the iframe CSS to affect the parent CSS.






share|improve this answer























  • Yes, I understand this but my JavaScript isn't loaded when the get request for my image isn't loaded.

    – Jonah
    Mar 6 at 22:22











  • Saying you need your code to run before your image is loaded? Move the code above the image, load JavaScript in the head of the document

    – Joshua Robinson
    Mar 6 at 22:24











  • The JavaScript is in the head.

    – Jonah
    Mar 6 at 22:31











  • Can simplified relevant code be added to the question? More than happy to help, confused about the part where an image failing to load throws a JavaScript error, unless there is an onLoad handler attached that’s has some buggy code

    – Joshua Robinson
    Mar 6 at 22:34











  • So I figured it out but I can't leave you hanging right because you'll go mad trying to understand. Basically, I had added a window.onload event at one point in my code and all my JavaScript was inside of this. So, while the image was waiting for the GET response, the JavaScript basically was unusable. So, I moved my JavaScript out of this window.onload and now it works perfectly because of this. Thank for being willing to help and if you wish to discuss this further, you can add me on discord Jonah#5945.

    – Jonah
    Mar 6 at 23:36















0














Only ancient email clients support running JavaScript, to do so opens so many security vulnerabilities, not advised. Iframe creates another browser context. Each browser context is a complete document environment, is not possible for the iframe CSS to affect the parent CSS.






share|improve this answer























  • Yes, I understand this but my JavaScript isn't loaded when the get request for my image isn't loaded.

    – Jonah
    Mar 6 at 22:22











  • Saying you need your code to run before your image is loaded? Move the code above the image, load JavaScript in the head of the document

    – Joshua Robinson
    Mar 6 at 22:24











  • The JavaScript is in the head.

    – Jonah
    Mar 6 at 22:31











  • Can simplified relevant code be added to the question? More than happy to help, confused about the part where an image failing to load throws a JavaScript error, unless there is an onLoad handler attached that’s has some buggy code

    – Joshua Robinson
    Mar 6 at 22:34











  • So I figured it out but I can't leave you hanging right because you'll go mad trying to understand. Basically, I had added a window.onload event at one point in my code and all my JavaScript was inside of this. So, while the image was waiting for the GET response, the JavaScript basically was unusable. So, I moved my JavaScript out of this window.onload and now it works perfectly because of this. Thank for being willing to help and if you wish to discuss this further, you can add me on discord Jonah#5945.

    – Jonah
    Mar 6 at 23:36













0












0








0







Only ancient email clients support running JavaScript, to do so opens so many security vulnerabilities, not advised. Iframe creates another browser context. Each browser context is a complete document environment, is not possible for the iframe CSS to affect the parent CSS.






share|improve this answer













Only ancient email clients support running JavaScript, to do so opens so many security vulnerabilities, not advised. Iframe creates another browser context. Each browser context is a complete document environment, is not possible for the iframe CSS to affect the parent CSS.







share|improve this answer












share|improve this answer



share|improve this answer










answered Mar 6 at 22:20









Joshua RobinsonJoshua Robinson

1,7861824




1,7861824












  • Yes, I understand this but my JavaScript isn't loaded when the get request for my image isn't loaded.

    – Jonah
    Mar 6 at 22:22











  • Saying you need your code to run before your image is loaded? Move the code above the image, load JavaScript in the head of the document

    – Joshua Robinson
    Mar 6 at 22:24











  • The JavaScript is in the head.

    – Jonah
    Mar 6 at 22:31











  • Can simplified relevant code be added to the question? More than happy to help, confused about the part where an image failing to load throws a JavaScript error, unless there is an onLoad handler attached that’s has some buggy code

    – Joshua Robinson
    Mar 6 at 22:34











  • So I figured it out but I can't leave you hanging right because you'll go mad trying to understand. Basically, I had added a window.onload event at one point in my code and all my JavaScript was inside of this. So, while the image was waiting for the GET response, the JavaScript basically was unusable. So, I moved my JavaScript out of this window.onload and now it works perfectly because of this. Thank for being willing to help and if you wish to discuss this further, you can add me on discord Jonah#5945.

    – Jonah
    Mar 6 at 23:36

















  • Yes, I understand this but my JavaScript isn't loaded when the get request for my image isn't loaded.

    – Jonah
    Mar 6 at 22:22











  • Saying you need your code to run before your image is loaded? Move the code above the image, load JavaScript in the head of the document

    – Joshua Robinson
    Mar 6 at 22:24











  • The JavaScript is in the head.

    – Jonah
    Mar 6 at 22:31











  • Can simplified relevant code be added to the question? More than happy to help, confused about the part where an image failing to load throws a JavaScript error, unless there is an onLoad handler attached that’s has some buggy code

    – Joshua Robinson
    Mar 6 at 22:34











  • So I figured it out but I can't leave you hanging right because you'll go mad trying to understand. Basically, I had added a window.onload event at one point in my code and all my JavaScript was inside of this. So, while the image was waiting for the GET response, the JavaScript basically was unusable. So, I moved my JavaScript out of this window.onload and now it works perfectly because of this. Thank for being willing to help and if you wish to discuss this further, you can add me on discord Jonah#5945.

    – Jonah
    Mar 6 at 23:36
















Yes, I understand this but my JavaScript isn't loaded when the get request for my image isn't loaded.

– Jonah
Mar 6 at 22:22





Yes, I understand this but my JavaScript isn't loaded when the get request for my image isn't loaded.

– Jonah
Mar 6 at 22:22













Saying you need your code to run before your image is loaded? Move the code above the image, load JavaScript in the head of the document

– Joshua Robinson
Mar 6 at 22:24





Saying you need your code to run before your image is loaded? Move the code above the image, load JavaScript in the head of the document

– Joshua Robinson
Mar 6 at 22:24













The JavaScript is in the head.

– Jonah
Mar 6 at 22:31





The JavaScript is in the head.

– Jonah
Mar 6 at 22:31













Can simplified relevant code be added to the question? More than happy to help, confused about the part where an image failing to load throws a JavaScript error, unless there is an onLoad handler attached that’s has some buggy code

– Joshua Robinson
Mar 6 at 22:34





Can simplified relevant code be added to the question? More than happy to help, confused about the part where an image failing to load throws a JavaScript error, unless there is an onLoad handler attached that’s has some buggy code

– Joshua Robinson
Mar 6 at 22:34













So I figured it out but I can't leave you hanging right because you'll go mad trying to understand. Basically, I had added a window.onload event at one point in my code and all my JavaScript was inside of this. So, while the image was waiting for the GET response, the JavaScript basically was unusable. So, I moved my JavaScript out of this window.onload and now it works perfectly because of this. Thank for being willing to help and if you wish to discuss this further, you can add me on discord Jonah#5945.

– Jonah
Mar 6 at 23:36





So I figured it out but I can't leave you hanging right because you'll go mad trying to understand. Basically, I had added a window.onload event at one point in my code and all my JavaScript was inside of this. So, while the image was waiting for the GET response, the JavaScript basically was unusable. So, I moved my JavaScript out of this window.onload and now it works perfectly because of this. Thank for being willing to help and if you wish to discuss this further, you can add me on discord Jonah#5945.

– Jonah
Mar 6 at 23:36

















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%2f55032891%2fhow-to-load-html-file-with-style-without-affecting-the-rest-of-the-page-styles%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

1928 у кіно

Захаров Федір Захарович

Ель Греко