Do you Java-script?
September 16, 2009 9:06 AM   Subscribe

Calling all Javascript Experts: I am trying to tweak a small javascript bookmarklet to improve its functionality. The fact I dont know HOW is turning out to be a bit of a challenge. Help me please!


This bookmarklet opens the webpage of html-pdf-converter but I want it to to open a new page and load the url where I am when I click on the bookmarklet. (I know it can be done because my other favourite bookmarklet does it for a different purpose) see code here:


Now if only I can get someone to help me pick the best bits from both and make it work.

EXTRA points, if someone can also get it to press the 'convert' button so all I get is a save/open dialogue.

In case you are wondering, I have tried using software on my computer to convert like cutepdf but the output is not nearly as good as this.

Many thanks
posted by london302 to Computers & Internet (10 answers total)
Response by poster: I dont know why there is so much space between window; and if. apologies
posted by london302 at 9:07 AM on September 16, 2009

I would try
posted by kmz at 9:23 AM on September 16, 2009

Response by poster: KMZ, I see what you tried there but sadly it still does the same thing and ignores the command. Any ideas on how we can use 'popw' which appears in the other example?
posted by london302 at 9:32 AM on September 16, 2009

popw there is a variable which actually gets assigned by I'm not sure why it's not working for you. It seems to be working here, though I haven't tried it in bookmarklet form. What browser are you using?
posted by kmz at 9:34 AM on September 16, 2009

posted by bitdamaged at 9:48 AM on September 16, 2009

doh I did kmz. That worked for me.
posted by bitdamaged at 9:53 AM on September 16, 2009

Best answer: Make sure your popup blocker is off London.

The following code opens your current location in a new window, and then creates a PDF. It works for me as a bookmarklet.

javascript:var win;''+escape(location.href)); win.document.onload="document.getElementById('form_html_to_pdf').submit()";
posted by trueluk at 12:17 PM on September 16, 2009

Response by poster: thanks all for your input.

Trueluk, your code does exactly as you say. One thing worth noting however: the original page ends up with the following text:


any way of fixing this?

thanks very much kmz, bitdamaged and trueluk
posted by london302 at 3:33 PM on September 16, 2009

Best answer: javascript:(function(){var win;''+escape(location.href)); win.document.onload=function(){document.getElementById('form_html_to_pdf').submit();};})();
posted by bbyboi at 2:47 AM on September 17, 2009

Response by poster: .bbyboi: Thanks/ This is very fast and does the job well . Any way it could open the pdf converter page in a new tab?
posted by london302 at 4:58 AM on September 17, 2009

« Older What's biting me?   |   "He's handy with his whip. . .and his lips!" Newer »
This thread is closed to new comments.