Browsing field

Got a LiveCode personal license? Are you a beginner, hobbyist or educator that's new to LiveCode? This forum is the place to go for help getting started. Welcome!

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller

Post Reply
cybernaut
Posts: 13
Joined: Wed Feb 09, 2011 2:57 pm

Browsing field

Post by cybernaut » Mon Jul 04, 2011 6:17 am

Hello, I have created a field on my stack and I trying to fill it with a webpage from the internet.
I have tried anything to bring the webpage to show it in that field I created but nothing it is working.
Anybody can help me? I am sure that probably the solution is pretty easy but I am new at this.
I am using this on a button:

on mouseUp
put URL "http://www.abc.net/" into Field "WebField"
end mouseUp

But the field does not resolve the URL, only giving me the html source code!!
Thank you
Herman

shaosean
Posts: 906
Joined: Thu Nov 04, 2010 7:53 am

Re: Browsing field

Post by shaosean » Mon Jul 04, 2011 9:23 am

You will probably want to look at the revBrowser features, but here is a quickie script

1. create an image control, call it "browserRect", set the dimensions to whatever you want
2. create a button, add this script

Code: Select all

on mouseUp
  local tBrowserID
  put revBrowserOpen(the windowID of this stack, "http://www.abc.net/") into tBrowserID  // creates a revBrowser instance and navigates to the website
  revBrowserSet tBrowserID, "rect", (the rect of image "browserRect")  // sets the dimensions of the browser instance to the dimensions of the image
end mouseUp
3. ???
4. profit

cybernaut
Posts: 13
Joined: Wed Feb 09, 2011 2:57 pm

Re: Browsing field

Post by cybernaut » Mon Jul 04, 2011 10:53 am

shaosean wrote:You will probably want to look at the revBrowser features, but here is a quickie script

1. create an image control, call it "browserRect", set the dimensions to whatever you want
2. create a button, add this script

Code: Select all

on mouseUp
  local tBrowserID
  put revBrowserOpen(the windowID of this stack, "http://www.abc.net/") into tBrowserID  // creates a revBrowser instance and navigates to the website
  revBrowserSet tBrowserID, "rect", (the rect of image "browserRect")  // sets the dimensions of the browser instance to the dimensions of the image
end mouseUp
3. ???
4. profit
THANK YOU!!!!!!!!
This was exactly what I wanted!
I never knew about this revBrowser I have to study the dictionary. I am new to all this.
Again, thank you!!
Herman

cybernaut
Posts: 13
Joined: Wed Feb 09, 2011 2:57 pm

Re: Browsing field

Post by cybernaut » Mon Jul 04, 2011 11:35 am

shaosean wrote:You will probably want to look at the revBrowser features, but here is a quickie script

1. create an image control, call it "browserRect", set the dimensions to whatever you want
2. create a button, add this script

Code: Select all

on mouseUp
  local tBrowserID
  put revBrowserOpen(the windowID of this stack, "http://www.abc.net/") into tBrowserID  // creates a revBrowser instance and navigates to the website
  revBrowserSet tBrowserID, "rect", (the rect of image "browserRect")  // sets the dimensions of the browser instance to the dimensions of the image
end mouseUp
3. ???
4. profit
I have successfully created a button to launch the website but what about if I want the website to automatically open when stack open? I have tried the same code with " On preopenstack" and "end preopenstack without success. What am I doing wrong?
Thanks
Herman

shaosean
Posts: 906
Joined: Thu Nov 04, 2010 7:53 am

Re: Browsing field

Post by shaosean » Mon Jul 04, 2011 11:44 am

preOpenStack is too early, try moving it to either the preOpenCard (might still be too early) or openCard

cybernaut
Posts: 13
Joined: Wed Feb 09, 2011 2:57 pm

Re: Browsing field

Post by cybernaut » Mon Jul 04, 2011 11:50 am

shaosean wrote:preOpenStack is too early, try moving it to either the preOpenCard (might still be too early) or openCard
Already tried without luck!
What could it be?
Herman

shaosean
Posts: 906
Joined: Thu Nov 04, 2010 7:53 am

Re: Browsing field

Post by shaosean » Mon Jul 04, 2011 11:53 am

Might be due to the way the revBrowser external works, so lets try this in your stack/card script

Code: Select all

on preOpenStack
  send "makeBrowserWork" to me in 0 seconds  // this causes the message to be put at the end of the queue
end preOpenStack

on makeBrowserWork
  local tBrowserID
  put revBrowserOpen(the windowID of this stack, "http://www.abc.net/") into tBrowserID  // creates a revBrowser instance and navigates to the website
  revBrowserSet tBrowserID, "rect", (the rect of image "browserRect")  // sets the dimensions of the browser instance to the dimensions of the image
end makeBrowserWork

cybernaut
Posts: 13
Joined: Wed Feb 09, 2011 2:57 pm

Re: Browsing field

Post by cybernaut » Mon Jul 04, 2011 11:59 am

shaosean wrote:Might be due to the way the revBrowser external works, so lets try this in your stack/card script

Code: Select all

on preOpenStack
  send "makeBrowserWork" to me in 0 seconds  // this causes the message to be put at the end of the queue
end preOpenStack

on makeBrowserWork
  local tBrowserID
  put revBrowserOpen(the windowID of this stack, "http://www.abc.net/") into tBrowserID  // creates a revBrowser instance and navigates to the website
  revBrowserSet tBrowserID, "rect", (the rect of image "browserRect")  // sets the dimensions of the browser instance to the dimensions of the image
end makeBrowserWork
It works!!! I was inserting the code in the wrong stack.
THANK YOU SOO MUCH!! if you were in Brisbane, Australia I will invite you to a few drinks on me!
Thanks mate!
Herman

maxvit99
Posts: 5
Joined: Fri Dec 02, 2011 10:08 pm

Re: Browsing field

Post by maxvit99 » Fri Dec 02, 2011 10:35 pm

Hello, I am having problems with this code:

Code: Select all

on mouseUp
   put empty into field "result"
   put field "URL" into tlocation
   local tBrowserID
   --   creates a revBrowser instance and navigates to the website
   put revBrowserOpen(the windowID of this stack, tlocation) into tBrowserID
   --   sets the dimensions of the browser instance to the dimensions of the image
   revBrowserSet tBrowserID, "rect", (the rect of image "browserRect")
end mouseUp
I am getting a
Navigation to the webpage was canceled
or a
This program cannot display the webpage
note in the field, instead of the contents of the field.
Wy is this happening :?:

maxvit99
Posts: 5
Joined: Fri Dec 02, 2011 10:08 pm

Re: Browsing field

Post by maxvit99 » Thu Dec 22, 2011 7:10 pm

Sorry, it was my antivirus (it was set on a property that let access to the internet only from Windows Internet Explorer). So what I did is turn it off and everything worked well :!:, except that when I typed a new address, it went to it and then, in some minutes it went back ot the first webpage that I visited. So what I do is close that app and then open it again and type the next address :cry: . Is there any other way to do that :?:

Post Reply