Jump to content

Trap IE page refresh


 Share

Recommended Posts

Hello,

I've been running this script for about a year now. I use

it to load a SQL reporting services report page. You'll see

in the script that I have disabled all of the links on the

web page because I don't want the user to go outside of the page.

It all works perfectly, until the user hits [F5] refresh.

The page reloads and all of my custom link event traps go

away. I really don't want to disable the refresh function,

but is there a way that I can trap for it ? Here is my

script:

#include <IE.au3>

$URL = $CmdLine[1]

$IsSSRS = StringInStr($URL,"http://sql05srv/Reports")

If $IsSSRS <> 1 Then

MsgBox (0,"Warning","This function can only be used with SSRS pages.")

Exit

EndIf

$oIE = _IECreate ($URL)

_IEPropertySet ($oIE, "addressbar", False)

_IEPropertySet ($oIE, "menubar", False)

_IEPropertySet ($oIE, "toolbar", False)

For $i = 0 to 9 Step 1

$oLink = _IELinkGetCollection($oIE,$i)

$sLinkId = $oLink.uniqueId

_IEHeadInsertEventScript($oIE, $sLinkId, "onclick", "alert('Function not available');return false;")

Next

Opt("WinTitleMatchMode", 2)

WinSetState("- Windows Internet Explorer", "", @SW_MAXIMIZE)

Exit

Thanks to anyone who can help !

Link to comment
Share on other sites

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

Dale,

Thanks. You got my gears turning with that example.

In my application, I do not want to disable the page

reload, I just want to disable some page links when a

reload happens. I ended up making the following script

which seams to work great:

#include <IE.au3>

Local $f_Abort = False, $i_ErrorStatusCode = $_IEStatus_Success

$URL = $CmdLine[1]

$IsSSRS = StringInStr($URL,"http://sql05srv/Reports")

If $IsSSRS <> 1 Then

MsgBox (0,"Warning","This function can only be used with SSRS pages.")

Exit

EndIf

$oIE = _IECreate ($URL)

_IEPropertySet ($oIE, "addressbar", False)

_IEPropertySet ($oIE, "menubar", False)

_IEPropertySet ($oIE, "toolbar", False)

Opt("WinTitleMatchMode", 2)

WinSetState("- Windows Internet Explorer", "", @SW_MAXIMIZE)

DisableLinks()

While __IEIsObjType($oIE, "browser")

While Not (String($oIE.readyState)="complete" Or $oIE.readyState = 4 Or $f_Abort)

If @error = $_IEStatus_ComError And __IEComErrorUnrecoverable() Then

$f_Abort = True

ExitLoop

EndIf

DisableLinks()

WEnd

$f_Abort = False

Sleep(200)

WEnd

Exit

Func DisableLinks()

_IELoadWait ($oIE)

For $i = 0 to 9 Step 1

$oLink = _IELinkGetCollection($oIE,$i)

$sLinkId = $oLink.uniqueId

_IEHeadInsertEventScript($oIE, $sLinkId, "onclick", "alert('Function not available');return false;")

Next

EndFunc

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...