0

For my Trac plugin, I have made an export script which converts contents to a different format. The result is an HTML code.

When I click the link, some browsers open the HTML code in a new tab, while others offer to download it as a .print file, depending on their specific settings I think. Opening this .print file shows the same HTML page as opening it directly, but locally instead of from the server.

How can I force it to always open in a new tab?
I think it might be a mimetype issue. If it is, which mimetype can I use to tell the browser to open the HTML code directly? I am currently using text/html as mimetype.

EDIT: some more info
To give some more insight, adapting from a comment of mine below:
I do not create the link myself. The link is provided by Trac, the bug tracking software the plugin is for, and what I do is implement the method that creates the HTML code and let it return the HTML code along with the mimetype. Trac then returns the HTML code either as a file, or as a new tab, when clicking on that content conversion link. What I am searching for is a possibility to specify in the HTML code or mimetype that it gets opened in a new tab directly.

  1. Maybe there is some kind of mimetype specifying the (HTML) text as an HTML web document instead of HTML file (if that distinction even exists).
  2. Or an HTML/XML header or doctype specifying whether it gets downloaded or opened by a browser. I think the browser need to get that information from somewhere.
  3. Or maybe there is an option to set in Trac.

I hope these ideas of mine about what could exist can help those of you who are versed with either or some of these to find a solution. I could not find a solution through my research yet.

Raimund Krämer
  • 1,255
  • 1
  • 11
  • 29
  • http://stackoverflow.com/a/16900840/1654265 – Andrea Ligios Nov 13 '15 at 13:01
  • 1
    It looks like it might be necessary to set `Content-Disposition` to [inline](http://stackoverflow.com/a/11894771/121694). However, it's hard-coded to `attachment` in [Mimeview.send_converted](http://trac.edgewall.org/browser/tags/trac-1.0.9/trac/mimeview/api.py?marks=1067#L1039). – RjOllos Nov 16 '15 at 21:48

1 Answers1

0

If you have a link that "directly" opens (not in a new tab) and you want it to open a new tab, one way of doing it is

<a href="url" target="_blank"> </a>

This will create a blank page, then paste the link there automagically and thus you will have a new tab with the desired page.

Xariez
  • 759
  • 7
  • 24
  • I think your answer is missing the answer. Did you want to write something after "one way of doing it is ."? Apart from that, your answer totally misses the question. It is about opening in a new tab instead of downloading, not instead of opening in the same tab. – Raimund Krämer Nov 13 '15 at 13:40
  • @D.Everhard I did write there but apparently StackOverflow translated it. Thats a mistake. Fixed - Thanks for pointing it out, whether it be a decent answer or not! – Xariez Nov 16 '15 at 20:09
  • Now it makes sense. Unfortunately I do not implement the link by myself. The link is provided by Trac, the bug tracking software the plugin is for, and what I do is implement the method the creates the HTML code and let it return the HTML code along with the mimetype. Trac then returns the HTML code either as a file, or as a new tab. What I am searching for is a possibility to specify in the HTML code or mimetype that it gets opened in a new tab directly. – Raimund Krämer Nov 16 '15 at 21:20
  • Hmm, afraid thats currently outside my knowledge circle then. Hope you get it resolved! ^^ – Xariez Nov 17 '15 at 22:48