/    Sign up×
Community /Pin to ProfileBookmark

Want Firefox 1.5 to show .pgn-file in frame and then access it’s text with Javascript

Hi!
A pgn-file is a plain text file. It’s used for chessgames.
I want Firefox 1.5.0.12 on Win XP SP2 to show the pgn-file in a frame when I click on the link.
That’s the first problem: Since I installed some years ago some chessprogram Firefox always asks what to do with a .pgn-file (Download dialog).

I know I can change this behaviour either in config:about or in some configuration file for mime types.
But how to do that??? (There are extensions for that, but only for Firefox 2 and higher. ): And I would prefer to change it via the about:config-file or in the mime-configuration file, some .rdf-file I think.

Then I want to access the plain text in that frame with javascript. How could I do that?

(If you need a pgn-file to test, just take any text-file and rename the ending to .pgn.)

You would help me alot!!

Thank you very much in advance!

Greetings
DH2006

to post a comment
JavaScript

7 Comments(s)

Copy linkTweet thisAlerts:
@dmboydMar 29.2009 — Is it a frame or an iframe or what? If it is one of those, I can't think of any way without editing your own configuration. If this is for other computers, it won't work except on your computer since your configuration doesn't affect others' configurations.

If it is for other computers, you might benefit from using the object element in the necessary page (note that if you're using frames, it goes in one of the framed pages, not the page with the frameset):
[code=html]<object type="text/plain" data="path/to/somefile.pgn" height="200" width="400">
<p>Your browser couldn't render the file.</p>
</object>[/code]


I hope that helps!

I'm still not sure if you would be able to access its contents though... Someone with more experience might be able to help you since the only other way I can think of would be to use AJAX, and for something this simple, I would think JS would have an easier answer.
Copy linkTweet thisAlerts:
@dh2006authorMar 29.2009 — I should have explained a bit more. It's only all running locally on my machine.

I start with an html-file that has an iframe that show a directory listing:

<iframe src="file:///C:/directory/" width="99%" height="400" name="dirView" scrolling="yes" marginheight="0" marginwidth="0" frameborder="0">

<p>no iframes</p>

</iframe>

Then I click on the pgn-filein that directory I want to see.

Firefox then shows the Download Dialogue. ):

I just hoped to concat the mime-question about Firefox with the Javascript-question would give me the answers to both tasks. =) (So I don'T have to find a forum where to ask the mime-questions seperatly. ?

Greetings

DH2006
Copy linkTweet thisAlerts:
@dmboydMar 29.2009 — Ohh... You would want to change your MIME types then... You can use the Windows registry to do it or you can go into the Folder Options dialog and configure it that way. I'll explain the Folder Options way since it is more user-friendly and often thought to be "safer":

[LIST=1]
  • [*]Open any folder in Windows Explorer and then go to Tools -> Folder Options.

  • [*]Click on the "File Types" tab.

  • [*]Click the button underneath the list that says "New".

  • [*]Use the file extension PGN.

  • [*]Click the button that is titled "Advanced" and for the "Associated File Type" field, choose "Text Document".

  • [*]Click OK to save that information and to close the window, then click OK to close the Folder Options dialog box.

  • [/LIST]


    You should now be able to use PGN files as text files...
    Copy linkTweet thisAlerts:
    @dh2006authorMar 29.2009 — I might try this in the general setting for windows. But that's not optimal.

    And there must be a way to tell Firefox to show it as plain text, as Firefox shows for example .txt-files as plain text too, though .txt-files aren't connected in the general setting to Firefox.
    Copy linkTweet thisAlerts:
    @dh2006authorMar 29.2009 — I just tried that. That doesn't work. I didn'T expect it to work though either. =)
    Copy linkTweet thisAlerts:
    @FangMar 30.2009 — You have answered the question yourself:
    If you need a pgn-file to test, just take any text-file and rename the ending to .pgn.[/QUOTE]So change the extension to [I]txt[/I]

    Alternatively use the server, either in the .htaccess or server side language, to change the header of the Content-type to text.
    Copy linkTweet thisAlerts:
    @dh2006authorMar 30.2009 — Luckily the Javascript code I had for directory listing, file reading and writing was easy to adjust.

    Of course, instead of one iframe I now need ~100 lines code for the directory listing and the file reading ( - without any real error handling still).

    Let's hope I won't encounter such a desing-failure in the future again.

    Ty again for the people who tried to help. =)

    Greetings DH2006
    ×

    Success!

    Help @dh2006 spread the word by sharing this article on Twitter...

    Tweet This
    Sign in
    Forgot password?
    Sign in with TwitchSign in with GithubCreate Account
    about: ({
    version: 0.1.9 BETA 5.20,
    whats_new: community page,
    up_next: more Davinci•003 tasks,
    coming_soon: events calendar,
    social: @webDeveloperHQ
    });

    legal: ({
    terms: of use,
    privacy: policy
    });
    changelog: (
    version: 0.1.9,
    notes: added community page

    version: 0.1.8,
    notes: added Davinci•003

    version: 0.1.7,
    notes: upvote answers to bounties

    version: 0.1.6,
    notes: article editor refresh
    )...
    recent_tips: (
    tipper: @AriseFacilitySolutions09,
    tipped: article
    amount: 1000 SATS,

    tipper: @Yussuf4331,
    tipped: article
    amount: 1000 SATS,

    tipper: @darkwebsites540,
    tipped: article
    amount: 10 SATS,
    )...