SitePoint Sponsor

User Tag List

Results 1 to 3 of 3
  1. #1
    SitePoint Enthusiast
    Join Date
    May 2006
    Posts
    78
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Question How do I edit this javascript to open a text file?

    Hi,
    This is a simple bookmarklet "Firefox Notepad" source @here:

    Code:
    javascript:(function(){s=document.selection?document.selection.createRange().text:window.getSelection?window.getSelection().toString():document.getSelection?document.getSelection():'';pwin=window.open('','_blank','menubar=yes,scrollbars=yes,location=no,height=550,width=700');with(pwin.document){if(s){write(s);close();}body.contentEditable='true';designMode='on';}if(window.focus){pwin.focus();setTimeout('pwin.focus()',125)};void(0);})()
    How to edit the above to open a text file instead of blank at the start?
    I tried the two obvious places and they didn't seem to work; Will spaces in the path be a problem?

    Sample path =
    C:\Documents and Settings\Compaq_Owner\Desktop\sample text.txt
    Thank you

  2. #2
    Forums Designer
    Join Date
    Jun 2004
    Posts
    422
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    You can't open files from computer via javascript.

  3. #3
    Programming Since 1978 silver trophybronze trophy felgall's Avatar
    Join Date
    Sep 2005
    Location
    Sydney, NSW, Australia
    Posts
    16,869
    Mentioned
    25 Post(s)
    Tagged
    1 Thread(s)
    The first step would be to upload the text file to the web so that you can specify its address properly in the window.open call.
    Stephen J Chapman

    javascriptexample.net, Book Reviews, follow me on Twitter
    HTML Help, CSS Help, JavaScript Help, PHP/mySQL Help, blog
    <input name="html5" type="text" required pattern="^$">


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •