From: Allison N. <dem...@ma...> - 2008-12-15 15:04:05
|
Pfft! Yeah, sure, I *could* do it that way, but where's the challenge? Where's the call to that human need to create, design, embellish! Thanks Eloy, that's a much nicer solution - and as a bonus, it brings the browser window to the foreground, and uses the preferred browser for the system :-) Alli On Monday, December 15, 2008, at 03:21PM, "Eloy Duran" <elo...@gm...> wrote: >Hi Alli, > >Not sure if this helps you out or not, >but if all you want to do is to open a new window with a specific URL >you should use: > >NSWorkspace.sharedWorkspace.openURL() > >Eloy > >On Dec 15, 2008, at 2:08 PM, Allison Newman wrote: > >> Oh, never mind, I figured it out.... You have to add the object to >> the application before modifying it's properties - apparently the >> ScriptingBridge class of the object isn't really resolved until the >> object is added to the application container. So this works: >> >> document_class = @safari.classForScriptingClass('document') >> document = document_class.alloc.init >> @safari.documents << document >> document.URL = url >> >> >> Alli >> >> >> >> On Monday, December 15, 2008, at 01:36PM, "Allison Newman" <dem...@ma... >> > wrote: >>> Hi everyone, >>> >>> I'm having a few problems scripting Safari from Ruby, and I'm >>> wondering if anyone else has had any problems/found solutions. >>> >>> I'm trying to open a URL in Safari. My first attempt looked like >>> this (please excuse any typos, I'm not on the computer that has the >>> source code....) >>> >>> require 'osx/cocoa' >>> include OSX >>> >>> OSX.require_framework 'ScriptingBridge' >>> >>> url = "http://www.blah.com/MyAccount.htm" >>> >>> @safari = >>> SBApplication.applicationWithBundleIdentifier("com.apple.Safari") >>> # so far, so good! >>> >>> # The following is no good, this gives me a document_class of >>> SBProxyByClass >>> document_class = @safari.classForScriptingClass('document') >>> document = document_class.alloc.init >>> document.URL = url >>> @safari.documents << document >>> >>> # the following works, but only if Safari already has a page open - >>> it changes this page to the new URL, which is not what I want to >>> do, I want to open either a new window, or a new tab. It also >>> fails if there is no document already open, as document is set to nil >>> document = @safari.documents.last >>> # document has a class of OSX::SafariDocument >>> document.URL = url >>> >>> #The following does not work, again, the class isn't right... >>> document = OSX::SafariDocument.alloc.init >>> # document.class = SBProxyByClass >>> document.URL = url >>> @safari.documents << document >>> >>> >>> So, I'm a little puzzled. Does anyone know how to do this properly? >>> >>> Alli >>> >>> ------------------------------------------------------------------------------ >>> SF.Net email is Sponsored by MIX09, March 18-20, 2009 in Las Vegas, >>> Nevada. >>> The future of the web can't happen without you. Join us at MIX09 >>> to help >>> pave the way to the Next Web now. Learn more and register at >>> http://ad.doubleclick.net/clk;208669438;13503038;i?http://2009.visitmix.com/ >>> _______________________________________________ >>> Rubycocoa-talk mailing list >>> Rub...@li... >>> https://lists.sourceforge.net/lists/listinfo/rubycocoa-talk >>> >>> >> >> ------------------------------------------------------------------------------ >> SF.Net email is Sponsored by MIX09, March 18-20, 2009 in Las Vegas, >> Nevada. >> The future of the web can't happen without you. Join us at MIX09 to >> help >> pave the way to the Next Web now. Learn more and register at >> http://ad.doubleclick.net/clk;208669438;13503038;i?http://2009.visitmix.com/ >> _______________________________________________ >> Rubycocoa-talk mailing list >> Rub...@li... >> https://lists.sourceforge.net/lists/listinfo/rubycocoa-talk > > >------------------------------------------------------------------------------ >SF.Net email is Sponsored by MIX09, March 18-20, 2009 in Las Vegas, Nevada. >The future of the web can't happen without you. Join us at MIX09 to help >pave the way to the Next Web now. Learn more and register at >http://ad.doubleclick.net/clk;208669438;13503038;i?http://2009.visitmix.com/ >_______________________________________________ >Rubycocoa-talk mailing list >Rub...@li... >https://lists.sourceforge.net/lists/listinfo/rubycocoa-talk > > |