Page 1 of 1

revBrowser - how to open new window

Posted: Sun Feb 08, 2015 9:40 pm
by snm
Is it possible to open link from one page opening new page in new window (or new tab)? This is working on any web browsers, but I can't find the solution with revBrowser and revBrowserCef.

Thanks in advance for help,
Marek

Re: revBrowser - how to open new window

Posted: Mon Feb 09, 2015 1:49 pm
by Klaus
Hi Marek,
snm wrote:Is it possible to open link from one page opening new page in new window?
yes, create a new stack with a browser overlay!
Sounds strange, but that's how LC works. 8)


Best

Klaus

Re: revBrowser - how to open new window

Posted: Mon Feb 09, 2015 2:06 pm
by snm
Thanks Klaus for reply, but how to script it to fire second browser?

Marek

Re: revBrowser - how to open new window

Posted: Mon Feb 09, 2015 2:31 pm
by Klaus
??? :shock:
I would use "revbrowseropen ...", or what am I missing?
In any case just like you opened the first browser :D

Re: revBrowser - how to open new window

Posted: Mon Feb 09, 2015 2:54 pm
by snm
I have web browser in my application. If I click the link on actual visited web page, revBrowser should go to that web page. It's OK if next page is declared to open in the same browser tab/window.
But revBrowser don't display the (next) page if it's declared to open in new tab or new window.

Marek.

Re: revBrowser - how to open new window

Posted: Mon Feb 09, 2015 2:57 pm
by Klaus
AHA, now I understand! :D
Sorry, no idea!

Re: revBrowser - how to open new window

Posted: Mon Feb 09, 2015 10:17 pm
by pthirkell
Does browserNewUrlWindow help? The browserNewUrlWindow message is sent to the current card of a stack containing a browser object when the browser object has opened a url in a new window.

on browserNewUrlWindow pInstanceId, pUrl
go stack (the owner of me)
end browserNewUrlWindow

Re: revBrowser - how to open new window

Posted: Tue Feb 10, 2015 11:42 am
by snm
No, this message is sent when a url has been opened in a new window.
My problem is how to open link declared to open in new window.

Marek

Re: revBrowser - how to open new window

Posted: Tue Feb 10, 2015 8:28 pm
by jacque
The only way I can think of is to create a new instance of the browser control. Then you'd need to figure out where to display it, and whether you need to create and script fake tab buttons, or open a new stack, or something else.

Re: revBrowser - how to open new window

Posted: Tue Feb 10, 2015 10:47 pm
by snm
Thans Jacque, I plan that, but can't find the link (url) to the content of new window. It works in Safari and other web browsers. I'm looking in the browser messages, but can't find any of them containing the url to target page opened in new window.

Marek

Re: revBrowser - how to open new window

Posted: Wed Feb 11, 2015 8:28 pm
by jacque
The browserBeforeNavigate message includes the URL as a parameter. You can catch that message and open the new instance using the parameter. See the dictionary, you'll probably want to set the global browserCancel to true to avoid navigation within the current instance.

Re: revBrowser - how to open new window

Posted: Wed Feb 11, 2015 10:10 pm
by Klaus
jacque wrote:The browserBeforeNavigate message includes the URL as a parameter. You can catch that message and open the new instance using the parameter. See the dictionary, you'll probably want to set the global browserCancel to true to avoid navigation within the current instance.
Yes, but how do we know that the new URL is supposed to be opened in a new window?
Seems like a "catch 22" to me so far :D

Re: revBrowser - how to open new window

Posted: Thu Feb 12, 2015 8:26 pm
by pthirkell
I think that browserNewUrlWindow pInstanceId, pUrl is intended to handle right-clicking on a link in a browser window to open a new window and display the clicked link. The handler does work (right click on a link and a browserNewUrlWindow handler placed in the card script will fire). The problem I have found is that the pURL parameter (the page you want to display in a browser object in the new window) isn't being passed - it remains empty. I have filed a bug report [14534].

This is the script I am trying to get working, placed in the card of the originating browser object. I previously also created a sub-stack called "newBrowserWindow" which is essentially the new window intended to display the passed URL (pUrl).

on browserNewUrlWindow pInstanceId, pUrl
local tBrowserId
go stack "newBrowserWindow"
put revBrowserOpen(the windowId of this stack, pURL) into tBrowserId
if tBrowserId is not an integer then
answer "Failed to open browser"
else
revBrowserSet tBrowserId, "rect", "0,0," & the width of this card & "," & the height of this card
end if
end browserNewUrlWindow

Re: revBrowser - how to open new window

Posted: Sat Feb 14, 2015 3:39 pm
by zaxos
Hey there pthirkell, i confirm that browserNewUrlWindows isn't working properly. You could try this tho:
Code for main stack:

Code: Select all

global pInstanceId, pUrl
global tBrowserId
global theUrl
on browserBeforeNavigate pInstanceId, pUrl
   put pUrl into theUrl
   go stack "newBrowserWindow"
end browserBeforeNavigate

on openBrowser
   repeat for each item tItem in revBrowserInstances()
      revBrowserClose tItem
   end repeat
   put revBrowserOpenCef(the windowId of this stack, "http://www.google.com") into tBrowserId
   if tBrowserId is not an integer then
      answer "Failed to open browser"
   else
      revBrowserSet tBrowserId, "rect", the rect of grc "Rectangle"
   end if
end openBrowser
Code for substack:

Code: Select all

global theUrl
local BrowserID
global tBrowserID
on openStack
   repeat for each item tItem in revBrowserInstances()
      if tItem is tBrowserID then 
         --do nothing
      else
         revBrowserClose tItem
      end if
   end repeat
   put revBrowserOpenCef(the windowId of this stack, theUrl) into BrowserID
   if tBrowserId is not an integer then
      answer "Failed to open browser"
   else
      revBrowserSet BrowserID, "rect", the rect of this card
   end if
end openStack

on resumeStack
   openStack
end resumeStack
EDIT: just seen that this have been mentioned. Anyway i'l leave the code there just in case.