Working around "location=", for debugging
-
How about sending a message to the webdialog once it's loaded and set a flag to indicate webdialog or not?
-
As I understand it, there's no reliable way for the plugin code to know when the webdialog has been loaded, except to wait for a "location=..." message. And, if I try to send that message in the browser environment, I crash. So, I seem to have a "chicken and egg" problem. Am I missing something?
-
Can't speak about the Mac, but I was able to register the skp: protocol in Firefox on Windows.
-
@richmorin said:
As I understand it, there's no reliable way for the plugin code to know when the webdialog has been loaded, except to wait for a "location=..." message. And, if I try to send that message in the browser environment, I crash. So, I seem to have a "chicken and egg" problem. Am I missing something?
wd.show { wd.execute_script('is_webdialog = true;') }
?
-
FWIW On Mac, the string from a WebDialog is:
Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10_6_4; en-us) AppleWebKit/533.18.1 (KHTML, like Gecko)
but from Safari its:
Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10_6_4; en-us) AppleWebKit/533.18.1 (KHTML, like Gecko) Version/5.0.2 Safari/533.18.5
So you could detect this.
Sure this is been discussed before, but isn't the simplest thing to install a scheme handler that does nothing?
-
Good catch! I had looked at the appVersion strings, but failed to notice the extra goo at the end of the Safari version.
I'm not sure what you mean by "isn't the simplest thing to install a scheme handler that does nothing". Could you please give more details?
-
Here is the comment block I put in my code. I think it summarizes what I know about this issue. Comments welcome...
# It's a bit tricky to determine whether this # method is running under SU or a web browser. # The first way I found, which is solid but # clunky, is to write a second copy of the HTML # file using a name such as DBG_main.html, # allowing this test to work; # # document.documentURI.match(/DBG_/) || # (location = string); # # Adam Billyard (AdamB on SketchUcation) pointed # out that Safari puts some extra goo at the end # of the appVersion string. So, here's a less # clunky (but possibly brittle) alternative; # # navigator.appVersion.match(/533\.18\.5$/) || # (location = string); # # Thomas Thomassen (thomthom on SketchUcation), # pointed out that JavaScript code may be reliably # sent from a block attached to the show() or # show_modal() call, as; # # wd.show_modal do # wd.execute_script('env_is_webdialog = true;') # end # # This allows the technique below to be used; # # env_is_webdialog && (location = string);
-
I was under the impression that the code block of show() and show_modal() did not work on the Mac.
Has this been fixed on SU 8.x ?? -
hmm.... you might be right about that... when you mention it I do imagine there was some issues...
-
@dan rathbun said:
I was under the impression that the code block of show() and show_modal() did not work on the Mac.
Has this been fixed on SU 8.x ??Dunno, in general, but a quick experiment worked for me. Then again, I was only setting a single variable.
-r
Advertisement