SVG in DIV not showing when added to DOM with coordinates of a certain HTML element










0















I am creating a browser extension, I am testing it on Chrome and Edge for now.
It puts a svg drawing upon some words that are in the web page adjusting its size according to the font.



Simple divs with the svg inside are added to the DOM.
I put zIndex= auto or inherit but I found a strange behaviour on a certain web page:
https://developer.mozilla.org/en-US/docs/Mozilla/Add-ons/WebExtensions/API/tabs/executeScript



If the extension puts a drawing on the words matching "tabs" the first occurrence in the title you can see on top of the page is not seen at all.
I checked with the developer tools and the div is present like others, just it does not appear.



function createDiv(x,y,size) 
var scrollX=window.scrollX;
var scrollY=window.scrollY;
var div=null;div=document.createElement('div');


div.className=CLASS_NAME;
div.style.position = 'absolute';
var color=COLOR;

div.style.opacity='0.6';

div.style.zIndex='auto';

div.style.top=(scrollY+(y)-size/4)+'px';
div.style.height=(size)+'px';
div.style.left=(scrollX+(x))+'px';
if (scrollX+(x)+size>window.innerWidth) div.style.left=window.innerWidth-size;
div.style.width=(size)+'px';

div.innerHTML='<svg ...>';
div.style.visibility='visible';
return div;
;
....
div=createDiv(param1,param2,param3);
document.body.appendChild(div);


(52.71875 118 110 for the parameters should be matching the first occurrence)



Is it a zIndex issue? Or another kind of HTML problem?










share|improve this question
























  • Please show an actual executable example of this, so that we can see what it actually does to the page in question. (F.e. rewrite it so that it can be applied via the browser console, when visiting that page.)

    – misorude
    Nov 13 '18 at 11:04











  • @misorude You can try with these 3 parameters: 52.71875,118,110. I think you can set the innerHTML field as you want. Perform your test on the above mentioned web page.

    – P5music
    Nov 13 '18 at 11:27












  • Sorry, not able to reproduce the issue you are describing doing that.

    – misorude
    Nov 13 '18 at 11:30











  • @misorude Do you mean you see the div correctly displayed?

    – P5music
    Nov 13 '18 at 11:30











  • z-index: auto is not going to work, the .document-head element that contains that headline has z-index: 88, so you need to go at least that high with the z-index on your element as well, if you want to see it on top.

    – misorude
    Nov 13 '18 at 11:35















0















I am creating a browser extension, I am testing it on Chrome and Edge for now.
It puts a svg drawing upon some words that are in the web page adjusting its size according to the font.



Simple divs with the svg inside are added to the DOM.
I put zIndex= auto or inherit but I found a strange behaviour on a certain web page:
https://developer.mozilla.org/en-US/docs/Mozilla/Add-ons/WebExtensions/API/tabs/executeScript



If the extension puts a drawing on the words matching "tabs" the first occurrence in the title you can see on top of the page is not seen at all.
I checked with the developer tools and the div is present like others, just it does not appear.



function createDiv(x,y,size) 
var scrollX=window.scrollX;
var scrollY=window.scrollY;
var div=null;div=document.createElement('div');


div.className=CLASS_NAME;
div.style.position = 'absolute';
var color=COLOR;

div.style.opacity='0.6';

div.style.zIndex='auto';

div.style.top=(scrollY+(y)-size/4)+'px';
div.style.height=(size)+'px';
div.style.left=(scrollX+(x))+'px';
if (scrollX+(x)+size>window.innerWidth) div.style.left=window.innerWidth-size;
div.style.width=(size)+'px';

div.innerHTML='<svg ...>';
div.style.visibility='visible';
return div;
;
....
div=createDiv(param1,param2,param3);
document.body.appendChild(div);


(52.71875 118 110 for the parameters should be matching the first occurrence)



Is it a zIndex issue? Or another kind of HTML problem?










share|improve this question
























  • Please show an actual executable example of this, so that we can see what it actually does to the page in question. (F.e. rewrite it so that it can be applied via the browser console, when visiting that page.)

    – misorude
    Nov 13 '18 at 11:04











  • @misorude You can try with these 3 parameters: 52.71875,118,110. I think you can set the innerHTML field as you want. Perform your test on the above mentioned web page.

    – P5music
    Nov 13 '18 at 11:27












  • Sorry, not able to reproduce the issue you are describing doing that.

    – misorude
    Nov 13 '18 at 11:30











  • @misorude Do you mean you see the div correctly displayed?

    – P5music
    Nov 13 '18 at 11:30











  • z-index: auto is not going to work, the .document-head element that contains that headline has z-index: 88, so you need to go at least that high with the z-index on your element as well, if you want to see it on top.

    – misorude
    Nov 13 '18 at 11:35













0












0








0








I am creating a browser extension, I am testing it on Chrome and Edge for now.
It puts a svg drawing upon some words that are in the web page adjusting its size according to the font.



Simple divs with the svg inside are added to the DOM.
I put zIndex= auto or inherit but I found a strange behaviour on a certain web page:
https://developer.mozilla.org/en-US/docs/Mozilla/Add-ons/WebExtensions/API/tabs/executeScript



If the extension puts a drawing on the words matching "tabs" the first occurrence in the title you can see on top of the page is not seen at all.
I checked with the developer tools and the div is present like others, just it does not appear.



function createDiv(x,y,size) 
var scrollX=window.scrollX;
var scrollY=window.scrollY;
var div=null;div=document.createElement('div');


div.className=CLASS_NAME;
div.style.position = 'absolute';
var color=COLOR;

div.style.opacity='0.6';

div.style.zIndex='auto';

div.style.top=(scrollY+(y)-size/4)+'px';
div.style.height=(size)+'px';
div.style.left=(scrollX+(x))+'px';
if (scrollX+(x)+size>window.innerWidth) div.style.left=window.innerWidth-size;
div.style.width=(size)+'px';

div.innerHTML='<svg ...>';
div.style.visibility='visible';
return div;
;
....
div=createDiv(param1,param2,param3);
document.body.appendChild(div);


(52.71875 118 110 for the parameters should be matching the first occurrence)



Is it a zIndex issue? Or another kind of HTML problem?










share|improve this question
















I am creating a browser extension, I am testing it on Chrome and Edge for now.
It puts a svg drawing upon some words that are in the web page adjusting its size according to the font.



Simple divs with the svg inside are added to the DOM.
I put zIndex= auto or inherit but I found a strange behaviour on a certain web page:
https://developer.mozilla.org/en-US/docs/Mozilla/Add-ons/WebExtensions/API/tabs/executeScript



If the extension puts a drawing on the words matching "tabs" the first occurrence in the title you can see on top of the page is not seen at all.
I checked with the developer tools and the div is present like others, just it does not appear.



function createDiv(x,y,size) 
var scrollX=window.scrollX;
var scrollY=window.scrollY;
var div=null;div=document.createElement('div');


div.className=CLASS_NAME;
div.style.position = 'absolute';
var color=COLOR;

div.style.opacity='0.6';

div.style.zIndex='auto';

div.style.top=(scrollY+(y)-size/4)+'px';
div.style.height=(size)+'px';
div.style.left=(scrollX+(x))+'px';
if (scrollX+(x)+size>window.innerWidth) div.style.left=window.innerWidth-size;
div.style.width=(size)+'px';

div.innerHTML='<svg ...>';
div.style.visibility='visible';
return div;
;
....
div=createDiv(param1,param2,param3);
document.body.appendChild(div);


(52.71875 118 110 for the parameters should be matching the first occurrence)



Is it a zIndex issue? Or another kind of HTML problem?







javascript html css browser google-chrome-extension






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Nov 13 '18 at 11:30







P5music

















asked Nov 13 '18 at 10:51









P5musicP5music

99812147




99812147












  • Please show an actual executable example of this, so that we can see what it actually does to the page in question. (F.e. rewrite it so that it can be applied via the browser console, when visiting that page.)

    – misorude
    Nov 13 '18 at 11:04











  • @misorude You can try with these 3 parameters: 52.71875,118,110. I think you can set the innerHTML field as you want. Perform your test on the above mentioned web page.

    – P5music
    Nov 13 '18 at 11:27












  • Sorry, not able to reproduce the issue you are describing doing that.

    – misorude
    Nov 13 '18 at 11:30











  • @misorude Do you mean you see the div correctly displayed?

    – P5music
    Nov 13 '18 at 11:30











  • z-index: auto is not going to work, the .document-head element that contains that headline has z-index: 88, so you need to go at least that high with the z-index on your element as well, if you want to see it on top.

    – misorude
    Nov 13 '18 at 11:35

















  • Please show an actual executable example of this, so that we can see what it actually does to the page in question. (F.e. rewrite it so that it can be applied via the browser console, when visiting that page.)

    – misorude
    Nov 13 '18 at 11:04











  • @misorude You can try with these 3 parameters: 52.71875,118,110. I think you can set the innerHTML field as you want. Perform your test on the above mentioned web page.

    – P5music
    Nov 13 '18 at 11:27












  • Sorry, not able to reproduce the issue you are describing doing that.

    – misorude
    Nov 13 '18 at 11:30











  • @misorude Do you mean you see the div correctly displayed?

    – P5music
    Nov 13 '18 at 11:30











  • z-index: auto is not going to work, the .document-head element that contains that headline has z-index: 88, so you need to go at least that high with the z-index on your element as well, if you want to see it on top.

    – misorude
    Nov 13 '18 at 11:35
















Please show an actual executable example of this, so that we can see what it actually does to the page in question. (F.e. rewrite it so that it can be applied via the browser console, when visiting that page.)

– misorude
Nov 13 '18 at 11:04





Please show an actual executable example of this, so that we can see what it actually does to the page in question. (F.e. rewrite it so that it can be applied via the browser console, when visiting that page.)

– misorude
Nov 13 '18 at 11:04













@misorude You can try with these 3 parameters: 52.71875,118,110. I think you can set the innerHTML field as you want. Perform your test on the above mentioned web page.

– P5music
Nov 13 '18 at 11:27






@misorude You can try with these 3 parameters: 52.71875,118,110. I think you can set the innerHTML field as you want. Perform your test on the above mentioned web page.

– P5music
Nov 13 '18 at 11:27














Sorry, not able to reproduce the issue you are describing doing that.

– misorude
Nov 13 '18 at 11:30





Sorry, not able to reproduce the issue you are describing doing that.

– misorude
Nov 13 '18 at 11:30













@misorude Do you mean you see the div correctly displayed?

– P5music
Nov 13 '18 at 11:30





@misorude Do you mean you see the div correctly displayed?

– P5music
Nov 13 '18 at 11:30













z-index: auto is not going to work, the .document-head element that contains that headline has z-index: 88, so you need to go at least that high with the z-index on your element as well, if you want to see it on top.

– misorude
Nov 13 '18 at 11:35





z-index: auto is not going to work, the .document-head element that contains that headline has z-index: 88, so you need to go at least that high with the z-index on your element as well, if you want to see it on top.

– misorude
Nov 13 '18 at 11:35












0






active

oldest

votes











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%2f53279379%2fsvg-in-div-not-showing-when-added-to-dom-with-coordinates-of-a-certain-html-elem%23new-answer', 'question_page');

);

Post as a guest















Required, but never shown

























0






active

oldest

votes








0






active

oldest

votes









active

oldest

votes






active

oldest

votes















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%2f53279379%2fsvg-in-div-not-showing-when-added-to-dom-with-coordinates-of-a-certain-html-elem%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

Use pre created SQLite database for Android project in kotlin

Darth Vader #20

Ondo