简体   繁体   中英

How to attach element to head DOM?

I have Iframe :

<iframe src="http://localhost/data/mapset/WEBLAYOUT"
        id="iframeMgMap"
        frameborder="0"
        scrolling="no"
        width="100%"
        onload=""
        height="800px"></iframe>

The iframe's DOM that how it looks in Elements section in debugger window:

<frameset id="mainFrame">
  <frameset id="secondaryFrame">
    <frameset id="firstpanel">
      <frame id="taskArea">
        #document
       <head>"some conent"<head></frame>
    </frameset>
  </frameset>

My question is how can I get head element inside frame with id="taskArea". And attach to it this element:

<link rel="stylesheet" href="../viewerfiles/viewer.css" type="text/css">

You can use jQuery:

var iframe = $('#iframeMgMap').contents();
var taskArea = iframe.find('#taskArea');
taskArea.append('<link rel="stylesheet" href="../viewerfiles/viewer.css" type="text/css">');

Cheers

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM