 |
 |
Getting Current URL Of WebView
|
 |
|
 |
|
Grizzled Veteran
Join Date: Jun 2002
Status:
Offline
|
|
Hi guys,
Something went wrong with the post, but anyway, what I want to do is get the current url of a webview and put that in a text field, I've looked through the WebView docs and cant see a way to get the url. Although there probably is:
Thanks,
Oliver
|
|
|
| |
|
|
|
 |
|
 |
|
Clinically Insane
Join Date: Oct 2001
Location: San Diego, CA, USA
Status:
Offline
|
|
I haven't used the WebKit much, but from the documentation it looks like you could do something along the lines of [[[webView backForwardList] currentItem] URLString].
|
|
Chuck
___
"Instead of either 'multi-talented' or 'multitalented' use 'bisexual'."
|
| |
|
|
|
 |
|
 |
|
Senior User
Join Date: Apr 2001
Location: Bolingbrook, IL, USA
Status:
Offline
|
|
I use
Code:
[[[[webView_main mainFrame] dataSource] request] URL]
That should work. Though it a bunch more calls than the guy above me's idea. 
|
|
|
| |
|
|
|
 |
|
 |
|
Grizzled Veteran
Join Date: Jun 2002
Status:
Offline
|
|
Hi guys,
I took Chuckits code and made it like:
Code:
NSString *currentURL = [[[helpWebView backForwardList] currentItem] URLString];
[helpURLBar setStringValue:(currentURL == nil ? @"" : currentURL)];
helpURLBar is the NSTextField. I load up my window that has the WebView in, it has nothing loaded. I click a button and it loads a website, but the text field still displays nothing, any ideas?
Thanks,
Oliver
|
|
|
| |
|
|
|
 |
|
 |
|
Clinically Insane
Join Date: Oct 2001
Location: San Diego, CA, USA
Status:
Offline
|
|
I'd go with Overmind's solution, personally. That seems more like how it's intended to be done. I just went for the more obvious method named "backForwardList."
|
|
Chuck
___
"Instead of either 'multi-talented' or 'multitalented' use 'bisexual'."
|
| |
|
|
|
 |
|
 |
|
Grizzled Veteran
Join Date: Jun 2002
Status:
Offline
|
|
Im a little confused by this, I tried Overminds code which is:
Code:
NSString *currentURL = [[[[helpWebView mainFrame] dataSource] request] URL];
[helpURLBar setStringValue:(currentURL == nil ? @"" : currentURL)];
I get this warning "initialization from incompatible pointer type". Here is a screeny of what Im trying to do:
Notice how the url bar is empty? What I want is the url of the page in the WebView in the TextField above it. The TextField is not editable, and I've tried it where its just normal, still doesn't work.
Any ideas?
Thanks,
Oliver
|
|
|
| |
|
|
|
 |
|
 |
|
Addicted to MacNN
Join Date: Nov 2002
Location: Seattle, WA
Status:
Offline
|
|
you probably want to get the -absoluteString from the NSURL
|
|
|
| |
|
|
|
 |
|
 |
|
Senior User
Join Date: Nov 2001
Location: State of Denial
Status:
Offline
|
|
Yeah. currentURL is an NSString, and [[[[helpWebView mainFrame] dataSource] request] URL] returns an NSURL (or so I'm assuming; I haven't worked with WebKit myself yet).
|
|
[Wevah setPostCount:[Wevah postCount] + 1];
|
| |
|
|
|
 |
 |
|
 |
|
|
|
|
|

|
|
 |
Forum Rules
|
 |
 |
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
|
HTML code is Off
|
|
|
|
|
|
 |
 |
 |
 |
|
 |
|