2017-02-09 78 views
1

有在HTML中的iframe:爲什麼我放棄了iframe的src?

<iframe id="iframeViewer3D" width="340" height="210" scrolling="no" src="/global/viewer.aspx?mode=3DWebGL&amp;xmp=-1-59-flexible_shaft_coupling_c172903000300.xmp&amp;previewCad=flexible_shaft_coupling_c172903000300&amp;h=210&amp;w=340&amp;version=3&amp;Lang=en&amp;fwsid=3DCC&amp;CF=0&amp;PMLOG=1&amp;DisplayMode=small&amp;manId=ACCES"></iframe> 

當我試圖讓這個iframe的與casperjs一個HTML:

var link = casper.getHTML('#iframeViewer3D', true); 

它返回的HTML的一部分,而不SRC:

<iframe id=\"iframeViewer3D\" width=\"340\" height=\"210\" scrolling=\"no\"></iframe> 

爲什麼src丟失以及如何獲取此src?我想這是因爲鏈接利茲到anoteher域

回答

1

你有沒有嘗試過直接獲取src值?

var link = casper.getElementAttribute('#iframeViewer3D', 'src'); 
+0

謝謝,但我的目標是簡單地得到帶有src的iframe標籤,沒有導航到「iframe」。 – ZaurK

+0

對不起,小姐明白了,並更新了我的帖子。 – dasmelch

+0

在這種情況下,我得到「null」,也許這個鏈接會導致另一個域... – ZaurK