View Full Version : WebKit - load pages without http:
Feb 24, 2007, 12:50 AM
I'm trying to make a web browser, and I'm stuck, how can I make it so that even if the user jjust types in www.msn.com it takes them to http://www.msn.com/ I can't get it to work, here's my code for connectURL: as apple has it on their site:
[[webView mainFrame] loadRequest:
Help would be greatly appreciated
Feb 24, 2007, 03:21 AM
You need a protocol to connect (i.e. http://). WebKit is not going to do this for you: you are the programmer fix it. It's pretty simple to check if the address starts with a recognised protocol and if not add http:// so the start of the string.
Feb 24, 2007, 08:09 PM
Erm, if it's a string, can't you just look for http in the beginning of the string, and if it's not there, do some "http://" + string or whatever...?
Feb 25, 2007, 08:03 PM
Ok I just reused the code from the other version I have, but now I have another problem, when I try to set its background color, it doesn't work, it still stays the line through type texture. It doesn't change it to the color I want like the other one does, its in the awakeFromNib and the function executes correctly, and its linked in MyDocument.nib so what's wrong with it now here's the code
[window setBackgroundColor:[NSColor colorWithDeviceRed: 0.837 green: 0.837 blue:0.837 alpha:1.0]];
Feb 26, 2007, 03:52 AM
Are you sure that the window background is not being correctly set? If you have a view that covers the window entirely then setting the window background will have no effect as the view will draw over it.
Feb 27, 2007, 01:43 AM
Yup the WebView is pretty big but it doesn't cover the window, the window is connected to the File's Owner window variable and awakeFromNib is being called. In regular apps that aren't document-based it works, but this one doesn't.
Feb 27, 2007, 01:52 AM
It won't even tell me the title of the window, so the window is connected, but its not telling me any information about it.
EDIT: Fixed it, I had to add a new NSObject that linked to the Window, since the window was based in the MyDocument class, it couldn't exactly modify the window, so yeah.