Register FAQ / Rules Forum Spy Search Today's Posts Mark Forums Read
Go Back   MacRumors Forums > Apple Systems and Services > Programming > Mac Programming

Reply
 
Thread Tools Search this Thread Display Modes
Old Apr 16, 2012, 01:55 AM   #1
gregor.hoch
macrumors member
 
Join Date: Apr 2011
qlmanage and html files: How can I jump to a location/anchor in a html file

I am trying to use qlmanage, a terminal command to perform Quick Look actions, to open a html file and jump to a specific location in the file (anchor). In the browser, I would just use file:///[LOCATION]/test.html#jump but that does not work with qlmanage. Below is an example that works with qlmanage and some attempts to jump to the anchor, which are not working.

Note that Quick Look itself can jump to anchors in html files. When I open links from emails with anchors, quick look jumps to the correct location. Hovering over the link in an email shows this:
'x-apple-ql-file:///[LOCATION]/test.html?/[LOCATION]/#jump

Thanks!



Works

Code:
/usr/bin/qlmanage -p '~/Desktop/test.html'
Doesn't work

Code:
/usr/bin/qlmanage -p '~/Desktop/test.html#jump'
/usr/bin/qlmanage -p 'file:///[LOCATION]/test.html#jump'
Example HTML File

Code:
        <head><meta http-equiv="Content-Type" content="text/html; charset=UTF-8"><meta charset="utf-8"><meta http-equiv="X-UA-Compatible" content="chrome=1"></head>
        
        <body>
        	<h1>Heading</h1>
        	<br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br>
        	<p id="jump">
        		jump here
        		<br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br>
        	<p>
    
    </body>
gregor.hoch is offline   0 Reply With Quote
Old Apr 16, 2012, 10:39 AM   #2
samwich
macrumors regular
 
Join Date: Aug 2007
To jump to an anchor in an HTML page you do not give an element an id with the anchor name. Instead you use
Code:
<a name="jump">Jump here</a>
Then you can use the URL
Code:
http://www.example.com/page.html#jump
http://www.w3schools.com/html/html_links.asp
__________________
my portfolio
samwich is offline   0 Reply With Quote
Old Apr 16, 2012, 11:08 AM   #3
gregor.hoch
Thread Starter
macrumors member
 
Join Date: Apr 2011
Thanks but that's not the problem. As far as I know, only very old user agents do not support id anchors and quicklook in Mail certainly handles id anchors fine. See the discussion here:
http://stackoverflow.com/questions/4...ith-name-or-id

In any case, qlmanage has the same problem with name anchors.
gregor.hoch is offline   0 Reply With Quote
Old Apr 16, 2012, 12:43 PM   #4
chown33
macrumors 603
 
Join Date: Aug 2009
Quote:
Originally Posted by gregor.hoch View Post
Hovering over the link in an email shows this:
'x-apple-ql-file:///[LOCATION]/test.html?/[LOCATION]/#jump

Doesn't work

Code:
/usr/bin/qlmanage -p '~/Desktop/test.html#jump'
/usr/bin/qlmanage -p 'file:///[LOCATION]/test.html#jump'
Your non-working examples don't follow the same syntax as your email example. I've hilited the difference in red.

I'm pointing this out for logical reasons, not because it works.


When I try the first example command, I get multiple warnings and errors output. They all say there's no such file. This is after creating the test.html file on my Desktop, and after running the posted command that works. (As run on Snow Leopard.)

Did you get any error messages? What did they say?


Your example HTML file is also missing a <!DOCTYPE>, and the <html> tags. My test file had them.

Last edited by chown33; Apr 16, 2012 at 12:49 PM.
chown33 is offline   0 Reply With Quote
Old Apr 16, 2012, 05:19 PM   #5
gregor.hoch
Thread Starter
macrumors member
 
Join Date: Apr 2011
I am getting the same error message. Something like file not found.

I guess I double pasted with the highlighted syntax example. Sorry for that. But I never got 'x-apple-ql-file' to work with qlmanage anyway.

Thanks for your trials!
gregor.hoch is offline   0 Reply With Quote
Old Apr 16, 2012, 06:24 PM   #6
chown33
macrumors 603
 
Join Date: Aug 2009
Quote:
Originally Posted by gregor.hoch View Post
I am getting the same error message. Something like file not found.
When posting questions, it's always a good idea to mention error messages. It's an even better idea to post the actual text of the complete error message.
http://www.mikeash.com/getting_answers.html


I'll also point out that qlmanage isn't really "a terminal command to perform Quick Look actions". It's a debugging and management tool. That's what it says in its man page. It should also be obvious because the QL window that shows the preview has the word "DEBUG" in its title.

I mention this because it's quite possible you'll have to write a command-line tool in order to get what you want. To that end, you should probably start by reading the Quick Look Programming Guide.

Just because a tool can be used for X doesn't mean it was designed for X, nor that it can accomplish all possible variations on X.
chown33 is offline   0 Reply With Quote

Reply
MacRumors Forums > Apple Systems and Services > Programming > Mac Programming

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -5. The time now is 09:14 PM.

Mac Rumors | Mac | iPhone | iPhone Game Reviews | iPhone Apps

Mobile Version | Fixed | Fluid | Fluid HD
Copyright 2002-2013, MacRumors.com, LLC