revBrowser - how to open new window

Anything beyond the basics in using the LiveCode language. Share your handlers, functions and magic here.

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller

Post Reply
snm
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 253
Joined: Fri Dec 09, 2011 11:17 am

revBrowser - how to open new window

Post by snm » Sun Feb 08, 2015 9:40 pm

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

Klaus
Posts: 14177
Joined: Sat Apr 08, 2006 8:41 am
Contact:

Re: revBrowser - how to open new window

Post by Klaus » Mon Feb 09, 2015 1:49 pm

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

snm
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 253
Joined: Fri Dec 09, 2011 11:17 am

Re: revBrowser - how to open new window

Post by snm » Mon Feb 09, 2015 2:06 pm

Thanks Klaus for reply, but how to script it to fire second browser?

Marek

Klaus
Posts: 14177
Joined: Sat Apr 08, 2006 8:41 am
Contact:

Re: revBrowser - how to open new window

Post by Klaus » Mon Feb 09, 2015 2:31 pm

??? :shock:
I would use "revbrowseropen ...", or what am I missing?
In any case just like you opened the first browser :D

snm
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 253
Joined: Fri Dec 09, 2011 11:17 am

Re: revBrowser - how to open new window

Post by snm » Mon Feb 09, 2015 2:54 pm

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.

Klaus
Posts: 14177
Joined: Sat Apr 08, 2006 8:41 am
Contact:

Re: revBrowser - how to open new window

Post by Klaus » Mon Feb 09, 2015 2:57 pm

AHA, now I understand! :D
Sorry, no idea!

pthirkell
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 93
Joined: Tue Nov 17, 2009 6:47 pm

Re: revBrowser - how to open new window

Post by pthirkell » Mon Feb 09, 2015 10:17 pm

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

snm
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 253
Joined: Fri Dec 09, 2011 11:17 am

Re: revBrowser - how to open new window

Post by snm » Tue Feb 10, 2015 11:42 am

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

jacque
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 7389
Joined: Sat Apr 08, 2006 8:31 pm
Contact:

Re: revBrowser - how to open new window

Post by jacque » Tue Feb 10, 2015 8:28 pm

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.
Jacqueline Landman Gay | jacque at hyperactivesw dot com
HyperActive Software | http://www.hyperactivesw.com

snm
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 253
Joined: Fri Dec 09, 2011 11:17 am

Re: revBrowser - how to open new window

Post by snm » Tue Feb 10, 2015 10:47 pm

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

jacque
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 7389
Joined: Sat Apr 08, 2006 8:31 pm
Contact:

Re: revBrowser - how to open new window

Post by jacque » Wed Feb 11, 2015 8:28 pm

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.
Jacqueline Landman Gay | jacque at hyperactivesw dot com
HyperActive Software | http://www.hyperactivesw.com

Klaus
Posts: 14177
Joined: Sat Apr 08, 2006 8:41 am
Contact:

Re: revBrowser - how to open new window

Post by Klaus » Wed Feb 11, 2015 10:10 pm

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

pthirkell
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 93
Joined: Tue Nov 17, 2009 6:47 pm

Re: revBrowser - how to open new window

Post by pthirkell » Thu Feb 12, 2015 8:26 pm

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

zaxos
Posts: 222
Joined: Thu May 23, 2013 11:15 pm

Re: revBrowser - how to open new window

Post by zaxos » Sat Feb 14, 2015 3:39 pm

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.
Knowledge is meant to be shared.

Post Reply