On Nov 5, 2004, at 19:12, Mike Chambers wrote:
First of all, just bought my license, and want to say what a great editor this has been thus far. Now, onto my question:
I am trying to duplicate the refresh safari command to work with FireFox. Here is what I have thus far:
osascript -e 'tell application "FireFox" to activate' osascript -e 'tell application "FireFox" to do JavaScript "window.location.reload();" in first document'
This works, except that FireFox does not refresh the active page.
Anyone have any ideas on how to get this working? mike c
Hi Mike & welcome to the fold.
You've helped me before on the Flash mailing list (many years ago now), so I thought I should help you as far as I can tonight (it's 9.30pm here)
The problems you are having is to do with the AppleScript syntax and limited AS support in Firefox.
The following Applescript works in Script Editor and just needs to be converted into TM working code. Don't have time to do so tonight : (
set theActiveURL to "http://www.macromedia.com/" tell application "Firefox" activate OpenURL theActiveURL end tell
You would use $TM_FILE_PATH to get the path to the file and load it as a local non-parsed file. IF you are previewing a file through a web server, then I guess you need to add a Project Shell Variable (info btn in project drawer when no file is selected) with the URL prefix and then use a bit of fancy footwork to add the variables together into a full URL.
I'll think about it over the weekend, but can't promise a solution, but I'm sure you - and many others - will have worked it out before then. : )
Hope that helped you a bit on the way.
Kind regards,
Mats
On Nov 5, 2004, at 21:19, Mats Persson wrote:
The following Applescript works in Script Editor and just needs to be converted into TM working code. Don't have time to do so tonight : (
set theActiveURL to "http://www.macromedia.com/" tell application "Firefox" activate OpenURL theActiveURL end tell
OK, so I am a naughty boy that's getting the missus rather angry now : )
Anyway, here's the AS that does what you want.
set theActiveURL to "JavaScript:window.location.reload();" tell application "Firefox" activate Get URL theActiveURL inside window 1 end tell
You just need to translate the above into TM command and you're up and running.
Attn: Sune. Apologies, if this reply is showing up inside the wrong thread. I created a new e-mail and copied Mike's text only and it still ended up in the wrong thread it seems.
Kind regards,
Mats
On Nov 5, 2004, at 21:46, Mats Persson wrote:
OK, so I am a naughty boy that's getting the missus rather angry now : )
Anyway, here's the AS that does what you want.
set theActiveURL to "JavaScript:window.location.reload();" tell application "Firefox" activate Get URL theActiveURL inside window 1 end tell
You just need to translate the above into TM command and you're up and running.
OK, stretching the world peace a little bit here, but the answer came to me. So here it is in FULL working order
1. Save the above AS snippet as a AppleScript file /Library/Scripts/TextMate/Firefox-BrowserReload.scpt. (Or whatever you like)
2. Type the following into your "Refresh in Firefox" Command: osascript /Library/Scripts/TextMate/Firefox-BrowserReload.scpt
That's it, it should now work just fine.
Have a nice weekend, and my fight for world peace begins now. : )
Kind regards,
Mats
On Nov 5, 2004, at 11:59 AM, Mats Persson wrote:
On Nov 5, 2004, at 21:46, Mats Persson wrote:
OK, so I am a naughty boy that's getting the missus rather angry now : )
Anyway, here's the AS that does what you want.
set theActiveURL to "JavaScript:window.location.reload();" tell application "Firefox" activate Get URL theActiveURL inside window 1 end tell
You just need to translate the above into TM command and you're up and running.
OK, stretching the world peace a little bit here, but the answer came to me. So here it is in FULL working order
- Save the above AS snippet as a AppleScript file
/Library/Scripts/TextMate/Firefox-BrowserReload.scpt. (Or whatever you like)
- Type the following into your "Refresh in Firefox" Command:
osascript /Library/Scripts/TextMate/Firefox-BrowserReload.scpt
That's it, it should now work just fine.
I tried this and it launch Firefox but not the file preview. Instead it just went to the default home page. The message in teh file I was trying to preview says:
/Users/tim/Library/Scripts/FirefoxReload.scpt: execution error: firefox-bin got an error: Can't get "JavaScript:window.location.reload();". (-1728)
??
-t
On Nov 6, 2004, at 00:41, Timothy Martens wrote:
On Nov 5, 2004, at 11:59 AM, Mats Persson wrote:
On Nov 5, 2004, at 21:46, Mats Persson wrote:
set theActiveURL to "JavaScript:window.location.reload();" tell application "Firefox" activate Get URL theActiveURL inside window 1 end tell
So here it is in FULL working order
- Save the above AS snippet as a AppleScript file
/Library/Scripts/TextMate/Firefox-BrowserReload.scpt. (Or whatever you like) 2. Type the following into your "Refresh in Firefox" Command: osascript /Library/Scripts/TextMate/Firefox-BrowserReload.scpt That's it, it should now work just fine.
I tried this and it launch Firefox but not the file preview. Instead it just went to the default home page. The message in teh file I was trying to preview says:
/Users/tim/Library/Scripts/FirefoxReload.scpt: execution error: firefox-bin got an error: Can't get "JavaScript:window.location.reload();". (-1728)
Timothy,
The problem you are having has to do with the fact that you don't have an open page in the browser to refresh. So, just as the "Refresh in Safari" command, you need to load the page you are working on in the browser first of all, and then the command will work.
However, in the greater good of all TM users, I have created the following scripts/commands: (available here: http://wiki.macromates.com/textmate/show/Howtos )
1. Preview in Browser: Safari, Firefox and IE5
2. Reload Browser: Safari, Firefox, IE5 and All 3 browsers.
Enjoy !
Kind regards,
Mats