Sign in to follow this  
Followers 0
wonnylee

iframe problem with no name

4 posts in this topic

I looked up the help file, and found there is _IEFrameGetObjByName function.

but Iframe that i want to using has no name, but an ID.

How can i get an object from IE IFrame using ID? instead of Name, since there's no name.

sourecode get with DebugBar is like this.

<iframe id=my-134 src="http://blahblahblah.jsp"></firame>

Share this post


Link to post
Share on other sites



_IEGetObjById()?

Share this post


Link to post
Share on other sites

_IEGetObjById()?

Actually, the id and name tags are not distinguished in the IE DOM. The only difference between them is that many elements can have the same name, but only one is allowed the same id. The function _IEFrameGetObjByName() works with either the name or id attribute. Demo:
#include <IE.au3>

$oIE = _My_Example()

Sleep(3000)
$oFrame = _IEFrameGetObjByName($oIE, "iFrameOne")
_IEBodyWriteHTML($oFrame, "Hello iFrame <b>One!</b>")
_IELoadWait($oFrame)

Sleep(3000)
$oFrame = _IEFrameGetObjByName($oIE, "iFrameTwo")
_IEBodyWriteHTML($oFrame, "Hello iFrame <b>Two!</b>")
_IELoadWait($oFrame)


; Derived directly from Dale Hohm's _IE_Example("iFrame") 
Func _My_Example()
    Local $s_html = "", $o_object
    $s_html &= "<HTML>" & @CR
    $s_html &= "<HEAD>" & @CR
    $s_html &= "<TITLE>_IE_Example('iframe')</TITLE>" & @CR
    $s_html &= "</HEAD>" & @CR
    $s_html &= "<BODY>" & @CR
    $s_html &= "<table cellspacing=6 cellpadding=6 border=1>" & @CR
    $s_html &= "<tr>" & @CR
    $s_html &= "<td><iframe name='iFrameOne' src='about:blank' title='iFrameOne'></iframe></td>" & @CR
    $s_html &= "<td>&lt;iframe name=&quot;iFrameOne&quot; src=&quot;about:blank&quot; title=&quot;iFrameOne&quot;&gt;</td>" & @CR
    $s_html &= "</tr>" & @CR
    $s_html &= "<tr>" & @CR
    $s_html &= "<td><iframe id='iFrameTwo' src='about:blank' title='iFrameTwo'></iframe></td>" & @CR
    $s_html &= "<td>&lt;iframe id=&quot;iFrameTwo&quot; src=&quot;about:blank&quot; title=&quot;iFrameTwo&quot;&gt;</td>" & @CR
    $s_html &= "</tr>" & @CR
    $s_html &= "</table>" & @CR
    $s_html &= "</BODY>" & @CR
    $s_html &= "</HTML>"
    $o_object = _IECreate()
    _IEDocWriteHTML($o_object, $s_html)
    _IEAction($o_object, "refresh")
    Local $oIFrameOne = _IEFrameGetObjByName($o_object, "iFrameOne")
    Local $oIFrameTwo = _IEFrameGetObjByName($o_object, "iFrameTwo")
    _IEBodyWriteHTML($oIFrameOne, '$oIFrameOne = _IEFrameGetObjByName($oIE, "iFrameOne")')
    _IEBodyWriteHTML($oIFrameTwo, '$oIFrameTwo = _IEFrameGetObjByName($oIE, "iFrameTwo")')
    Return $o_object
EndFunc  ;==>_IE_Example

^_^


Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law

Share this post


Link to post
Share on other sites

This helped me too, thanks!

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0