Jump to content

Open link in new window


Maximon
 Share

Recommended Posts

Hello, guys!

I need to open link in new window or tab, but do it from my current window, else while doing _IECreate() I loose the session.

Something like right mouse button click - how can I do it, please help!

WinActivate('[CLASS:IEFrame]')
WinWaitActive('[CLASS:IEFrame]')
Send('^t') ;new tab
ControlSetText('[CLASS:IEFrame]', "", '[CLASS:Edit; INSTANCE:1]', 'http://www.autoitscript.com/')
;~ ControlClick('[CLASS:IEFrame]', "", '[CLASS:ToolbarWindow32; INSTANCE:3]', 1)
Send('{ENTER}')

Cheers, FireFox.

Edited by FireFox
Link to comment
Share on other sites

Here's a solution that does not use Send:

#include <IE.au3>
$oIE = _IE_Example()
$oLinks = _IELinkGetCollection($oIE)
For $oLink in $oLinks
    If String(_IEPropertyGet($oLink, "innertext")) = "user forum" Then
        $oLink.target = "_blank"
        _IEAction($oLink, "click")
    EndIf
Next

Watch out for pop-up blockers that may block the new window.

Dale

Free Internet Tools: DebugBar, AutoIt IE Builder, HTTP UDF, MODIV2, IE Developer Toolbar, IEDocMon, Fiddler, HTML Validator, WGet, curl

MSDN docs: InternetExplorer Object, Document Object, Overviews and Tutorials, DHTML Objects, DHTML Events, WinHttpRequest, XmlHttpRequest, Cross-Frame Scripting, Office object model

Automate input type=file (Related)

Alternative to _IECreateEmbedded? better: _IECreatePseudoEmbedded  Better Better?

IE.au3 issues with Vista - Workarounds

SciTe Debug mode - it's magic: #AutoIt3Wrapper_run_debug_mode=Y

Doesn't work needs to be ripped out of the troubleshooting lexicon. It means that what you tried did not produce the results you expected. It begs the questions 1) what did you try?, 2) what did you expect? and 3) what happened instead?

Reproducer: a small (the smallest?) piece of stand-alone code that demonstrates your trouble

Link to comment
Share on other sites

OK, I found.

It should be done before:

WinActivate(_IEPropertyGet($myIE,"hwnd"))

Also ControlSetText didn't work in my IE, so I did it another way:

$IEhandle = WinGetHandle('[CLASS:IEFrame; ACTIVE]')
$ie2 = _IEAttach ($IEhandle, "HWnd")
_IENavigate($ie2, $link)
Link to comment
Share on other sites

Dale - thanks, but in IE6 your solution doesn't work, it opens link in the same window

I can think of no reason for this to be the case with IE6. Nothing has changed in that DOM behavior to my knowledge. Can you verify that this works as you say in IE6 and works as I say in more recent IE versions? Did you run the code just as I supplied it to test or are you basing your feedback on an attempt to adapt my example to your code?

Dale

Free Internet Tools: DebugBar, AutoIt IE Builder, HTTP UDF, MODIV2, IE Developer Toolbar, IEDocMon, Fiddler, HTML Validator, WGet, curl

MSDN docs: InternetExplorer Object, Document Object, Overviews and Tutorials, DHTML Objects, DHTML Events, WinHttpRequest, XmlHttpRequest, Cross-Frame Scripting, Office object model

Automate input type=file (Related)

Alternative to _IECreateEmbedded? better: _IECreatePseudoEmbedded  Better Better?

IE.au3 issues with Vista - Workarounds

SciTe Debug mode - it's magic: #AutoIt3Wrapper_run_debug_mode=Y

Doesn't work needs to be ripped out of the troubleshooting lexicon. It means that what you tried did not produce the results you expected. It begs the questions 1) what did you try?, 2) what did you expect? and 3) what happened instead?

Reproducer: a small (the smallest?) piece of stand-alone code that demonstrates your trouble

Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...