It is currently Sat Jan 25, 2020 10:20 pm

All times are UTC + 1 hour




Post new topic Reply to topic  [ 6 posts ] 
Author Message
 Post subject: JavaScript not enabled in Linux?
PostPosted: Sat Nov 01, 2014 11:35 pm 
Offline
Enthusiast
Enthusiast
User avatar

Joined: Tue May 28, 2013 10:51 pm
Posts: 539
Location: Europe
Greetings to all,

very simple issue Image Javascript seems to be disabled in WebGadget on Linux.

Works fine both on Windows and OS X. I've updated/installed both libwebkitgtk 1.0 and 3.0 but without any help. I tried importing webkit_settings_get_enable_javascript() and/or webkit_settings_set_enable_javascript() function but they seem to be unavailable in libwebkitgtk*.so.

Ubuntu 12.04 + PB 5.31

Any clues?

_________________
"If you lie to the compiler, it will get its revenge."
Henry Spencer
https://www.pci-z.com/


Top
 Profile  
Reply with quote  
 Post subject: Re: JavaScript not enabled in Linux?
PostPosted: Sun Nov 02, 2014 12:19 pm 
Offline
Addict
Addict
User avatar

Joined: Thu Apr 21, 2005 2:38 pm
Posts: 1678
Location: Germany
On my Ubuntu 14.04 x64 with KDE scripting languages are enabled by default in the WebGadget on PB 5.31 with GTK 2...

You may try to enable scripting languages with the following example code. It checks whether scripting languages are enabled and tries to enable scripting languages when disabled:
Code:
EnableExplicit

#G_TYPE_INT = 6 << 2

ImportC ""
  g_object_get_property(*Object.GObject, PropertyName.P-UTF8, *PropertyValue.GValue)
  g_object_set_property(*Object.GObject, PropertyName.P-UTF8, *PropertyValue.GValue)
EndImport

ImportC "-lwebkitgtk-1.0"
  webkit_web_settings_new()
  webkit_web_view_set_settings(*WebkitWebView, *WebkitSettings)
EndImport

Define PropertyName.S
Define PropertyValue.GValue
Define WebkitSettings.I

OpenWindow(0, 200, 100, 600, 300, "WebGadget", #PB_Window_Invisible)
WebGadget(0, 10, 10, 580, 280, "")

; ----- Check if scripting languages are enabled
WebkitSettings = webkit_web_settings_new()
PropertyValue\g_type = #G_TYPE_INT
g_object_get_property(WebkitSettings, "enable-scripts", @PropertyValue)

If g_value_get_int_(@PropertyValue)
  MessageRequester("Info", "Scripting languages are already enabled!")
Else
  ; ----- Enable scripting languages
  g_value_set_int_(@PropertyValue, #True)
  g_object_set_property(WebkitSettings, "enable-scripts", @PropertyValue)

  ; ----- Store changed settings
  webkit_web_view_set_settings(GadgetID(0), WebkitSettings)

  ; ----- Check new settings
  g_object_get_property(WebkitSettings, "enable-scripts", @PropertyValue)

  If g_value_get_int_(@PropertyValue) = #True
    MessageRequester("Info", "Scripting languages are now enabled!")
  Else
    MessageRequester("Error", "Sorry, but enabling of scripting languages failed!")
  EndIf
EndIf


Top
 Profile  
Reply with quote  
 Post subject: Re: JavaScript not enabled in Linux?
PostPosted: Sun Nov 02, 2014 1:51 pm 
Offline
Enthusiast
Enthusiast
User avatar

Joined: Tue May 28, 2013 10:51 pm
Posts: 539
Location: Europe
Shardik wrote:
On my Ubuntu 14.04 x64 with KDE scripting languages are enabled by default in the WebGadget on PB 5.31 with GTK 2...

You may try to enable scripting languages with the following example code. It checks whether scripting languages are enabled and tries to enable scripting languages when disabled
Hi Shardik,

thank you for the code, I finally understood how some other stuff works! :) Your code didn't seem to do the trick (since it claims scripts are enabled however it still didn't work), but when I put it like this, it works.

Code:
EnableExplicit

ImportC ""
  g_object_set(*Object.GObject, PropertyName.P-UTF8, *PropertyValue.GValue, Null.b)
EndImport

ImportC "-lwebkitgtk-1.0" ;can be changed with ImportC "-lwebkitgtk-3.0" and gtk3 subsystem
  webkit_web_settings_new()
  webkit_web_view_set_settings(*WebkitWebView, *WebkitSettings)
EndImport

Define WebkitSettings.i

  If OpenWindow(0, 0, 0, 1024, 768, "WebGadget", #PB_Window_SystemMenu | #PB_Window_ScreenCentered)
    WebGadget(0, 10, 10, 1004, 748, "https://www.whatismybrowser.com/")
    WebkitSettings = webkit_web_settings_new()
    g_object_set(WebkitSettings, "enable-scripts", #True, #Null)
    webkit_web_view_set_settings (GadgetID(0), WebkitSettings)
    Repeat
    Until WaitWindowEvent() = #PB_Event_CloseWindow
  EndIf


Image

Thank you thousand times! :)

_________________
"If you lie to the compiler, it will get its revenge."
Henry Spencer
https://www.pci-z.com/


Top
 Profile  
Reply with quote  
 Post subject: Re: JavaScript not enabled in Linux?
PostPosted: Sun Nov 02, 2014 9:11 pm 
Offline
Addict
Addict
User avatar

Joined: Thu Apr 21, 2005 2:38 pm
Posts: 1678
Location: Germany
bbanelli wrote:
Your code didn't seem to do the trick (since it claims scripts are enabled however it still didn't work),...

Thank you for your testing. You are right. My fault was in obtaining the default setting of WebKitGTK with webkit_web_settings_new() instead of getting the settings of PB's WebGadget. It seems that no WebKitGTK function exists to query the current settings of PB's WebGadget... :oops:

Because of scripting languages are enabled by default in WebKitGTK's settings, we may shorten our code even more:
Code:
EnableExplicit

ImportC "-lwebkitgtk-1.0"
  webkit_web_settings_new()
  webkit_web_view_set_settings(*WebkitWebView, *WebkitSettings)
EndImport

Define WebkitSettings.I

OpenWindow(0, 100, 100, 1024, 800, "WebGadget", #PB_Window_ScreenCentered | #PB_Window_SystemMenu)
WebGadget(0, 10, 10, 1004, 780, "https://www.whatismybrowser.com/")

; ----- Get Webkit's default setting (with scripting languages enabled)
WebkitSettings = webkit_web_settings_new()
; ----- Store Webkit's default settings in WebGadget
webkit_web_view_set_settings(GadgetID(0), WebkitSettings)

Repeat
Until WaitWindowEvent() = #PB_Event_CloseWindow


The following code is an example on how to obtain a selection of important settings from WebKitGTK's default settings:
Code:
EnableExplicit

#G_TYPE_INT = 6 << 2

ImportC ""
  g_object_get_property(*Object.GObject, PropertyName.P-UTF8, *PropertyValue)
EndImport

ImportC "-lwebkitgtk-1.0"
  webkit_web_settings_new()
EndImport

Define Info.S
Define WebkitSettings.I

Procedure.S GetWebkitSetting(PropertyName.S)
  Shared WebkitSettings.I

  Protected PropertyValue.GValue

  PropertyValue\g_type = #G_TYPE_INT
  g_object_get_property(WebkitSettings, PropertyName, @PropertyValue)

  If g_value_get_int_(@PropertyValue)
    ProcedureReturn "Yes"
  Else
    ProcedureReturn "No"
  EndIf
EndProcedure

WebkitSettings = webkit_web_settings_new()

If WebkitSettings
  Info + "Embedded scripting languages:" + #TAB$ + GetWebkitSetting("enable-scripts") + #CR$
  Info + "Support for java applets: " + #TAB$ + #TAB$ + #TAB$ + GetWebkitSetting("enable-java-applet") + #CR$
  Info + "Web audio: " + #TAB$ + #TAB$ + #TAB$ + #TAB$ + #TAB$ + #TAB$ + GetWebkitSetting("enable-webaudio") + #CR$
  Info + "WebGL: " + #TAB$ + #TAB$ + #TAB$ + #TAB$ + #TAB$ + #TAB$ + #TAB$ + GetWebkitSetting("enable-webgl") + #CR$
  Info + "Plugins: " + #TAB$ + #TAB$ + #TAB$ + #TAB$ + #TAB$ + #TAB$ + GetWebkitSetting("enable-plugins") + #CR$
  Info + "Javascript can access clipboard:" + #TAB$ + GetWebkitSetting("javascript-can-access-clipboard") + #CR$
  Info + "Javascript can open windows:" + #TAB$ + #TAB$ + GetWebkitSetting("javascript-can-open-windows-automatically") + #CR$
EndIf

MessageRequester("WebKit default settings", Info)


Top
 Profile  
Reply with quote  
 Post subject: Re: JavaScript not enabled in Linux?
PostPosted: Sun Nov 02, 2014 10:20 pm 
Offline
Enthusiast
Enthusiast
User avatar

Joined: Tue May 28, 2013 10:51 pm
Posts: 539
Location: Europe
Hi Shardik,

can you explain why are you using the following piece of code:

Code:
#G_TYPE_INT = 6 << 2


Why don't just write 24? Or you are using this to pad some bits or what?

Thanks for your time! :)

With my best,

Bruno

_________________
"If you lie to the compiler, it will get its revenge."
Henry Spencer
https://www.pci-z.com/


Top
 Profile  
Reply with quote  
 Post subject: Re: JavaScript not enabled in Linux?
PostPosted: Mon Nov 03, 2014 9:43 am 
Offline
Addict
Addict
User avatar

Joined: Thu Apr 21, 2005 2:38 pm
Posts: 1678
Location: Germany
bbanelli wrote:
can you explain why are you using the following piece of code:

Code:
#G_TYPE_INT = 6 << 2


Why don't just write 24? Or you are using this to pad some bits or what?

Of course you are right: it would be easier to simply write 24 instead of 6 << 2... :wink:

But I have chosen to write 6 << 2 because the GObject Reference Manual contains the following type definition:
G_TYPE_INT

#define G_TYPE_INT G_TYPE_MAKE_FUNDAMENTAL (6)

The fundamental type corresponding to gint.

The macro G_TYPE_MAKE_FUNDAMENTAL() simply shifts the type value 2 bit positions to the left. In order for me to don't have to remember what the the macro G_TYPE_MAKE_FUNDAMENTAL() does, it's simpler to define 6 << 2. If I now have to define another one of the multitude of G_TYPEs, for example a string, I only have to change the value 6 to 16 and I obtain the type definition for string:
Code:
#G_TYPE_STRING = 16 << 2


Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 6 posts ] 

All times are UTC + 1 hour


Who is online

Users browsing this forum: No registered users and 2 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
Jump to:  
cron

 


Powered by phpBB © 2008 phpBB Group
subSilver+ theme by Canver Software, sponsor Sanal Modifiye