Dan Bratt Posted February 16, 2010 Posted February 16, 2010 Hello, I've been running this script for about a year now. I useit to load a SQL reporting services report page. You'll seein the script that I have disabled all of the links on theweb 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 goaway. I really don't want to disable the refresh function,but is there a way that I can trap for it ? Here is myscript:#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.") ExitEndIf$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;")NextOpt("WinTitleMatchMode", 2)WinSetState("- Windows Internet Explorer", "", @SW_MAXIMIZE)ExitThanks to anyone who can help !
DaleHohm Posted February 16, 2010 Posted February 16, 2010 Please see how to prevent/control refresh, navigation or close of a webpage 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
Dan Bratt Posted February 17, 2010 Author Posted February 17, 2010 Dale, Thanks. You got my gears turning with that example. In my application, I do not want to disable the pagereload, I just want to disable some page links when areload happens. I ended up making the following scriptwhich 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.") ExitEndIf$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)WEndExitFunc 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;") NextEndFunc
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now