Select elements from all window.frames and apply events

0

How can I select and manipulate elements of all window.frames being generated by each SVG within a <object> tag that I put on the page?

I'm trying to add events click() to elements <g> of the .svg files loaded dynamically into divs within the element object using the data attribute. The files and the index page are in the same domain.

For the time being, I'm only able to manipulate the elements when the window index is given. where svg is. I thought it was possible to load everything in the main window to take advantage of a single document.

But apparently ...

W3.org 13.5 Notes on embedded documents

  

"An embedded document is entirely independent of the document in which it is embedded"

"An embedded document is completely independent of the document it is embedded in."

W3School - The Window Object

  

"If a document contains frames (tags), the browser creates a window object for the HTML document, and one additional window object for each frame."

"If a document contains frames (tags), the browser creates a window object for the HTML document and an additional window object for each frame."

This image is the DOM panel scenario

For each added svg added a new index and a Window .

Theindexisthus

whereeachWindowintheDOMpanelisthepaththatisbeingassignedattrdata.

<!-- Html reduzido só para mostrar em que posição do
Html ele está e como estão seus atributos, lembrando
que o attr data recebe um php:pdo query e a div .svg
é gerado dinamicamente através de um condição e echo
php -->

<html> 
 <head>
   <script/> 
 </head>     
      
      <body>
          
          <div></div>
          <div></div>...

       <?php 

         if($condicao){
        
          echo " 
          
          <div class='svg'>

          <object id='svg_id' data= ' ".$evt['local']." ' type='image/svg+xml' ></object>

          </div>";
        
        ?>
        
</html>

The way I'm accessing the SVG elements is as follows, I did both with Javascript and also tried with Jquery .

ps: Jquery is not going to post because the code is based on javascript, instead of the contentDocument I tried with contents () but at the end, even with Jquery, I only got it when I mixed the contentDocument together with a Window index.

ToselectallelementsofSVGandWindowItriedtouseselectorsalwaystryingtheirallor(*)functions.Butintheend,wheneverIusedaselectorofthisIgetstuckhavingtochooseaWindowindex.

Enjoying,whatdoesthis#Documentmean?

Notice that the <g> from above, from SVG One, is receiving events, and from below, SVG Two, no, I would like everyone to be, and in the future SVGs inserted.

    
asked by anonymous 20.02.2018 / 23:36

0 answers