如何访问Iframe中的元素

时间:2013-01-18 19:40:09

标签: javascript greasemonkey

  

可能重复:
  Javascript - Get element from within an iFrame

我正在尝试使用页面上的greasemonkey选择选项。 document.getElementById(“q10”)返回null。我确定这与iframe有关,但我不知道如何访问它。

这是加载iframe的地方。

  <td valign="top" height="88%" colspan="2">
    <iframe id="initialtextFrame" name="initialtextFrame" title="Survey Questions" frameborder="0" scrolling="auto" style="height: 100%; width: 100%"
        src= '/hc/64261160/?cmd=file&amp;file=preChatSurveyContent&amp;site=64261160&amp;sessionkey=H909985739716063515-5531034935655418229K8398902&amp;survey=Pre-Chat' 
    >This functionality requires frames.To read the LivePerson accessibility policy, please go to the <a href='http://www.liveperson.com/help/accessibility.asp'>Liveperson accessibility policy page</a>.<img src="/hcp/window3/common/trans.gif" width="10" alt="" /></iframe>
  </td>

这是我想在框架中选择的选项

<select tabindex="3" name="ude!1841972" id="q10" size="1">
    <option id="q10r0" value="" label="" selected='selected'>Select One</option>
    <option id="q10r1" value="Chat-Field Tech-Denver Metro" label="Chat-Field Tech-Denver Metro" >Chat-Field Tech-Denver Metro</option>
    <option id="q10r2" value="Chat-Field Tech-CO Springs-SLC, UT" label="Chat-Field Tech-CO Springs-SLC, UT" >Chat-Field Tech-CO Springs-SLC, UT</option>
    <option id="q10r3" value="Chat-Field Tech-Outstate CO-MT-UT-Wy" label="Chat-Field Tech-Outstate CO-MT-UT-Wy" >Chat-Field Tech-Outstate CO-MT-UT-Wy</option>
</select>

尝试document.getElementById(“q10r3”)和“q10”都返回null

0 个答案:

没有答案