ttt1107
November 24, 2009, 12:02am
#1
How would you tell a web view to load a url?
The web view is:
property webVIEW : missing value
The HTML box is
property HTMLBOX : missing value
Also how would you use the same properties above to search from a search provider such as google or yahoo?
You’d get the URL from and use something like setMainFrameURL_(theURL)
elspub
November 24, 2009, 10:12pm
#3
to search google use this url:
where searchString is just that.
If you want to be a bit more carefull you should “%20” encode the spaces in your searchString
so that “applescript and google searching” becomes “applescript%20and%20google%20searching”
which you can use the following handler, but its mainly a couple lines of text item delmiters:
For other search engines its usually just a matter of running a search with them and looking at the URL of the page they load after searching.
elspub:
If you want to be a bit more carefull you should “%20” encode the spaces in your searchString
so that “applescript and google searching” becomes “applescript%20and%20google%20searching”
which you can use the following handler, but its mainly a couple lines of text item delmiters:
You can also use the NSString method stringByAddingPercentEscapesUsingEncoding:, which should escape all illegal characters.
elspub
November 25, 2009, 1:27am
#5
much better. I’m starting to see the the light of ASOC
ttt1107
November 25, 2009, 1:39am
#6
Ok this is what I have:
on searchHTML_(sender)
set theurl to HTMLBAR's stringValue()
set theurl to theurl as string
webWIEW's setMainFrameURL_(theurl)
end searchHTML_
But it doesn’t load the entered url which is this exactly: http://www.youtube.com
In your first message, you said it was called HTMLBOX, not HTMLBAR.
You’ve also misspelt webVIEW as webWIEW.
ttt1107
November 25, 2009, 6:27am
#9
Lol sorry it was just misspelled, thanks for your help though.
ttt1107
November 25, 2009, 6:49am
#10
Ok i hav another question how would you get the url of the current page? Like say I click a link on a page and it takes me to another page and the url box doesn’t update so how would I update the url?
You can answer these questions pretty easily by opening Xcode Help and searching for WebView. Just look through the instance methods; that’s what I do.
You’ve seen what setMainFrameURL_ does, so you might start with mainFrameURL…
ttt1107
November 25, 2009, 5:49pm
#12
Wow thanks i didn’t know that!