How can i disable JavaScript in WebGadget ??
FireFox v19.0.2 lets me have Option to [•] disable JavaScript
i'd like to do same thing in PureBasic's WebGadget
WebGadget disable JavaScript
- VB6_to_PBx
- Enthusiast
- Posts: 627
- Joined: Mon May 09, 2011 9:36 am
WebGadget disable JavaScript
PureBasic .... making tiny electrons do what you want !
"With every mistake we must surely be learning" - George Harrison
- VB6_to_PBx
- Enthusiast
- Posts: 627
- Joined: Mon May 09, 2011 9:36 am
Re: WebGadget disable JavaScript
anyone know how to disable JavaScript in PureBasic's WebGadget ??
PureBasic .... making tiny electrons do what you want !
"With every mistake we must surely be learning" - George Harrison
Re: WebGadget disable JavaScript
I have the same question!
Have a code that loads web pages but I keep getting an error message window from Windows:
"An error has occurred in the script on this page!"
I do not want the window to be opened. Anyone know how it's done?
Have a code that loads web pages but I keep getting an error message window from Windows:
"An error has occurred in the script on this page!"
I do not want the window to be opened. Anyone know how it's done?
Re: WebGadget disable JavaScript
> "An error has occurred in the script on this page"
I've been using this for years to prevent the above message.
It's not originally my code, but I put it in an easy procedure.
I've been using this for years to prevent the above message.
It's not originally my code, but I put it in an easy procedure.
Code: Select all
Procedure HideWebGadgetErrors(gad)
SetGadgetAttribute(gad,#PB_Web_BlockPopups,#True)
id.IWebBrowser2=GetWindowLongPtr_(GadgetID(gad),#GWL_USERDATA)
id\put_Silent(#True) ; Suppress JavaScript error messages.
EndProcedure
I compile using 5.31 (x86) on Win 7 Ultimate (64-bit).
"PureBasic won't be object oriented, period" - Fred.
"PureBasic won't be object oriented, period" - Fred.
Re: WebGadget disable JavaScript
silent script and html5 compatible browser. I changed the browser emulation (Code 11001 :Internet Explorer 11)This link for other browser emulation http://msdn.microsoft.com/en-us/library ... s.85).aspx
Code: Select all
RegCreateKeyValue("HKEY_LOCAL_MACHINE\Software\Microsoft\Internet Explorer\Main\FeatureControl\FEATURE_BROWSER_EMULATION", GetFilePart(ProgramFilename()), "11001", #REG_DWORD, ".")
Code: Select all
;WebGadget HTML5 compatible
;Contributor: Sphere Users Pure Basic
;
;Create 29-08-2014
;Update 29-08-2014
;
Enumeration Window
#MainForm
EndEnumeration
Enumeration Gadget
#URL
#WebGadget
EndEnumeration
Global Url.s="http://html5test.com/"
;-
;- U.T. Registry
Procedure RegConvertRegKeyToTopKeyAndKeyName(Key.s)
Shared topKey,KeyName.s
temp.s=StringField(Key,1,"\")
temp=UCase(temp)
Select temp
Case "HKEY_CLASSES_ROOT"
topKey=#HKEY_CLASSES_ROOT
Case "HKEY_CURRENT_USER"
topKey=#HKEY_CURRENT_USER
Case "HKEY_LOCAL_MACHINE"
topKey=#HKEY_LOCAL_MACHINE
Case "HKEY_USERS"
topKey=#HKEY_USERS
Case "HKEY_CURRENT_CONFIG"
topKey=#HKEY_CURRENT_CONFIG
EndSelect
PositionSlash=FindString(Key,"\",1)
KeyName.s=Right(Key,(Len(Key)-PositionSlash))
EndProcedure
ProcedureDLL RegSetValue(Key.s, ValueName.s, Value.s, Type, ComputerName.s) ; Sets a Value
;Type can be #REG_SZ / #REG_DWORD / #REG_BINARY / #REG_EXPAND_SZ
;For REG_BINARY type use Hexa value as String
;Returns 1 if successful or 0 if it fails
Shared RegWow64.l,RegEx,topKey,KeyName.s
RegConvertRegKeyToTopKeyAndKeyName(Key)
If ComputerName = "."
If RegEx
GetHandle = RegOpenKeyEx_(topKey,KeyName,0,#KEY_ALL_ACCESS|RegWow64,@hKey)
Else
GetHandle = RegOpenKey_(topKey,KeyName,@hKey)
EndIf
Else
lReturnCode = RegConnectRegistry_(ComputerName,topKey,@lhRemoteRegistry)
If RegEx
GetHandle = RegOpenKeyEx_(lhRemoteRegistry,KeyName,0,#KEY_ALL_ACCESS|RegWow64,@hKey)
Else
GetHandle = RegOpenKey_(lhRemoteRegistry,KeyName,@hKey)
EndIf
EndIf
If GetHandle = #ERROR_SUCCESS
lpcbData = 255
lpData.s = Space(255)
Select Type
Case #REG_EXPAND_SZ
GetHandle = RegSetValueEx_(hKey, ValueName, 0, #REG_EXPAND_SZ, @Value, Len(Value) + 1)
Case #REG_SZ
GetHandle = RegSetValueEx_(hKey, ValueName, 0, #REG_SZ, @Value, Len(Value) + 1)
Case #REG_DWORD
lValue = Val(Value)
GetHandle = RegSetValueEx_(hKey, ValueName, 0, #REG_DWORD, @lValue, 4)
Case #REG_BINARY
LenBuffer=Len(Value)/2
*RegBuffer=AllocateMemory(LenBuffer)
For n=0 To LenBuffer-1
OctetHexa.s=Mid(Value,(n*2)+1,2)
Octet=Val("$"+OctetHexa)
PokeB(*RegBuffer+n,Octet)
Next
GetHandle= RegSetValueEx_(hKey,ValueName,0,#REG_BINARY,*RegBuffer,LenBuffer)
FreeMemory(*RegBuffer)
EndSelect
RegCloseKey_(hKey)
ergebnis = 1
ProcedureReturn ergebnis
Else
RegCloseKey_(hKey)
ergebnis = 0
ProcedureReturn ergebnis
EndIf
EndProcedure
ProcedureDLL RegCreateKey(Key.s, ComputerName.s)
;It create subkey if KeyPath don't exist
;Returns 1 if successful or 0 if it fails
Shared RegWow64.l,RegEx,topKey,KeyName.s
RegConvertRegKeyToTopKeyAndKeyName(Key)
lpSecurityAttributes.SECURITY_ATTRIBUTEs
If ComputerName = "."
If RegEx
GetHandle = RegCreateKeyEx_(topKey,KeyName,0,0,#REG_OPTION_NON_VOLATILE,#KEY_ALL_ACCESS|RegWow64,@lpSecurityAttributes,@hNewKey,@GetHandle)
Else
GetHandle = RegCreateKey_(topKey,KeyName,@hNewKey)
EndIf
Else
lReturnCode = RegConnectRegistry_(ComputerName, topKey, @lhRemoteRegistry)
If RegEx
GetHandle = RegCreateKeyEx_(lhRemoteRegistry,KeyName,0,0,#REG_OPTION_NON_VOLATILE,#KEY_ALL_ACCESS|RegWow64,@lpSecurityAttributes,@hNewKey,@GetHandle)
Else
GetHandle = RegCreateKey_(lhRemoteRegistry,KeyName,@hNewKey)
EndIf
EndIf
If GetHandle = #ERROR_SUCCESS
GetHandle = RegCloseKey_(hNewKey)
CreateKey = #True
Else
CreateKey = #False
EndIf
ProcedureReturn CreateKey
EndProcedure
ProcedureDLL RegCreateKeyValue(Key.s,ValueName.s,Value.s,Type,ComputerName.s) ; Creates a Key and a Value in a Single Command
;Type can be #REG_SZ or #REG_DWORD
;Returns 1 if successful or 0 if it fails
RegCreateKey(Key,ComputerName)
ProcedureReturn RegSetValue(Key,ValueName,Value,Type,ComputerName)
EndProcedure
;-
;-Test Area
Procedure NavigationCallback(Gadget, NewUrl.s)
Debug "new " + NewUrl + " - " + "old " + Url
If NewUrl <> Url
SetGadgetText(Gadget, NewUrl)
Url = NewUrl
EndIf
ProcedureReturn #PB_ProcessPureBasicEvents
EndProcedure
Procedure MainFormShow()
OpenWindow(#MainForm, 0, 0, 1024, 768,"WebGadget HTML5 compatible",#PB_Window_ScreenCentered|#PB_Window_SystemMenu)
WebGadget(#WebGadget, 0, 0, 1024, 768, Url)
;SetGadgetAttribute(#WebGadget, #PB_Web_NavigationCallback, @NavigationCallback())
SetGadgetAttribute(#WebGadget, #PB_Web_BlockPopups, #True)
SetGadgetAttribute(#WebGadget, #PB_Web_BlockPopupMenu, #True)
myBrowser.IWebBrowser2 = GetWindowLong_(GadgetID(#WebGadget), #GWL_USERDATA)
myBrowser\put_Silent(#True) ;Suppress error warnings in WebGadget
myBrowser\put_Left(0)
EndProcedure
Procedure Start()
RegCreateKeyValue("HKEY_LOCAL_MACHINE\Software\Microsoft\Internet Explorer\Main\FeatureControl\FEATURE_BROWSER_EMULATION", GetFilePart(ProgramFilename()), "11001", #REG_DWORD, ".")
MainFormShow()
EndProcedure
Start()
Repeat : Until WaitWindowEvent() = #PB_Event_CloseWindow
➽ Windows 11 64-bit - PB 6.21 x64 - AMD Ryzen 7 - NVIDIA GeForce GTX 1650 Ti
Sorry for my bad english and the Dunning–Kruger effect
Re: WebGadget disable JavaScript
Thanks for your nice tips. I will test them soon.
Re: WebGadget disable JavaScript
Fantastic!falsam wrote:silent script and html5 compatible browser. I changed the browser emulation (Code 11001 :Internet Explorer 11)
This is why I asked for "Thank you"/"Karma" on forum!
