I really don’t understand how to set a default page for web view. I’ve used the forum search, and read all posts about web view, but I need some help.
I have a web view in a panel, and it works just fine if I type the URL in the text field and hit return, but I can’t figure out how to set a default page (if it can’t be done with IB or in the GUI, I need to know what files to edit) -Or- instead of having to press return in the text field, is there a way to make a “go” button?
I use a subroutine similar to the following to set a web view’s url. I’ve included a couple handlers to illustrate it’s usage.
property URL_Home_Page : "http://www.apple.com/"
on clicked theObject
if name of theObject is "goHome" then --> Set it when the user clicks the Home button
Display_URL("http://bbs.macscripter.net/")
end if
end clicked
on opened theObject
if name of theObject is "MyWindow" then --> Set it whenever the window opens
Display_URL(URL_Home_Page)
end if
end opened
to Display_URL(theURL)
try
set URLWithString to call method "URLWithString:" of class "NSURL" with parameter theURL
set requestWithURL to call method "requestWithURL:" of class "NSURLRequest" with parameter URLWithString
set mainFrame to call method "mainFrame" of object (view "WebView" of window "MyWindow")
call method "loadRequest:" of mainFrame with parameter requestWithURL
on error the_error
log the_error
end try
end Display_URL