Reason to start download in same tab vs new tab? - javascript

I would like to know why and what is the difference between starting a download in the same tab / a new tab. Clicking the link will eventually start downloading, despite it's a new tab or same tab.
So can anyone explain me, what is the significance of doing this? Any help is appreciated :)
Example
<a href="https://jqueryui.com/resources/download/jquery-ui-1.9.2.custom.zip" >Current Tab Download</a><br>
<a href="https://jqueryui.com/resources/download/jquery-ui-1.9.2.custom.zip" target='_blank'>New Tab Download</a>

The actual behaviour is just a matter of settings the right Content-Disposition and Content-Type.
Starting in a new tab is usually just a work around for when the right HTTP headers are not set server-side.
Only exception I could think of would be for PDF files, if you want the user to be able to see the document right in the browser (through a PDF viewer) without navigating out of you website/app then yes, opening a new tab/popup could actually make some sense.

New tab is generally preffered when you want to preserve the content of the current tab and you want it to be their in the browser hoping user would want to come back to it. Because our site should never be left behind.

Related

Can you make an html link that does not let you click back to previous page, or show the previous link in your history?

I am working on a client site where the client has requested that there be a button (basic a link) that links to another page like google, in case an abusive significant other busts into the room while a woman is reading about how to get assistance. The tricky part is that I am trying to figure out to link to a page that will open int he same windows, but no let you go back to the site by clicking the browser's back button, or show up in "history". I have built a lot of website and never heard of this being possible without the use of a custom browser extension or something.
My question is ..
Is there a way to do this? Possible some JS magic? Just wondering
You're looking for location.replace().
<button onclick='location.replace("https://www.google.com");'>Click to close</button>
Instead of creating a new entry in browser history, it replaces the current one.
Note: Unfortunately, it's blocked by [SO]. But just try it in your app. It does work.
Second note: If you combine this with initially opening the to be hidden page in a new tab (target="_blank") => no history.
However, the best method and advice for such cases is browsing in incognito: Ctrl+Shift+N. Once closed, it's gone, with all history in the session. Pressing Ctrl+Shift+T in a new browser window won't bring the formerly opened tabs back.
IMHO, this technique should be clearly detailed in the "Precautions" section of your client's website, also advising on having another "normal" browsing session opened in a background browser window, with a few neutral tabs open on subjects that wouldn't raise any suspicions: cooking recipes, things for children, cosmetics, etc...
I am not sure about your question.
But on click you can open Iframe
<iframe src="www.google.com" style="border:none;"></iframe>

window.open() method with IE 8 - Force window to open outside of tabs

I am trying to make a program that is opened by physically clickng on the .HTML file, not through a web-page, and I need it to open up in its own window, NOT the same window in a new tab, without giving warnings.
I can not just change the settings in internet explorer on everyones computer.
So far the ONLY thing I have come up with that will make the window open up without a new tab is to have a secondare html file that uses window.open() to open the main file with the correct parameters.
if I do:
window.open('mainFile.html','_self','width=540, height=880')
it still opens it up in the same window with a new tab, and doesn't resize it.
if I do:
window.open('mainFile.html','','width=540, height=880')
window.close('secondFile.html')
It opens the main one up in a new window, but prompts the user to close the first file. I don't want anyone to know that the second file is not the main file. This ONLY needs to work in IE-8 with default settings.
*For clarification, the window.open() javascript method is called immediately and automatically upon opening the secondary file, so it can open the main file right away. If someone can think of a clever way to acheive the same results without any extra work on the program users parts, I am open to suggestions.
*I know this has to be possible in some way, as another programmer here made a program in the past with javascript, opened the same way my file is, and it does exactly what this one needs to. but unfortunately, they are not available for questioning and the source code is hidden and not accessable.
I GOT IT! Took a ridiculous amount of experimenting, but it works flawlessly now. I feel bad for asking this question now, as it was an extremely simple solution, but for anyone interested, I used a second helper .html file with the lines as follows
<SCRIPT LANGUAGE="JavaScript">
window.open('','_self',''); // this makes the window re-open itself via javascript
window.open('directory/myRealFile','_blank',','width=540,height=880,resizable=yes,scrollbars=yes');
window.close(); // since javascript opened it, it will close without a prompt
</script>

downloading images using javascript from a single Chrome tab

i came across this script on the web:
javascript:(function(){function I(u){var t=u.split('.'),e=t[t.length-1].toLowerCase();return {gif:1,jpg:1,jpeg:1,png:1,mng:1}[e]}function hE(s){return s.replace(/&/g,'&').replace(/>/g,'>').replace(/</g,'<').replace(/"/g,'"');}var q,h,i,z=open().document;z.write('<p>Images linked to by '+hE(location.href)+':</p><hr>');for(i=0;q=document.links[i];++i){h=q.href;if(h&&I(h))z.write('<p>'+q.innerHTML+' ('+hE(h)+')<br><img src="'+hE(h)+'">');}z.close();})()
And it fairly opens up all the images of a tab whose address bar you run the script in, in a new tab.
But that new tab, opens up as an about:blank tab, and when i press Ctrl+S to download the page, and hence thereby getting all the images opened in that tab, what i hope would happen doesn't.
Ctrl+S doesn't work on about:blank, and i kinda hoped there would be some way to download those images opened in this kind of tab. How do i do this? Is there any way in JavaScript to achieve this?
i searched around the web, and found wget, but i didn't really get it. Is there any easier way altogether to just download images from a tab using javascript?

Open url in new tab using javascript without click an anchor

i read a lot of solutions but all of them are clicking a url, and it works, but my client ask me to do is users opens his website, it automatically open a new tab with some special offers , so my question, is there any way to open a new tab without any user intervention? , maybe a jquery plugin?, i know the tabs rely on the web browser, but it have to be a way, a lot of web pages does it,but how?
Greetings
Without modifying the configuration of browser, the answer is no, only trusted event can open a new window (or tab)
You may ask if your client could change their browser's configuration to allow a popup window from an untrusted javascript program.
Write script in your page to open new page:
<script>
window.open("specialOffers.aspx");
</script>
and in the "specialOffers.aspx" page in the tag write:
<base target="_blank"/>

How to serve a page with only a title bar and content, nothing else?

I have a web page jammed full with a few hundred rows of tabular numerical data. It's fearsome. The user wants to see as many data rows as he can in one single view, without scrolling vertically. I'm thinking to serve that page with just a title bar -- no back or refresh button, no address bar, no Google toolbar, no status pane, nothing but a title bar. The user reaches the page by way of a normal html link.
Is there a way to do that in the CGI that writes the page? The CGI is already writing content and cache-control headers.
If not, then (next best thing) is there a way to do it with JavaScript, without opening a new browser window, perhaps in the onload event handler?
Thanks!
Is there a way to do that in the CGI that writes the page?
No.
If not, then (next best thing) is there a way to do it with JavaScript, without opening a new browser window, perhaps in the onload event handler?
Well, you could, on onload open a new ("chromeless") browser window with your page, but that's about it.
You can't control the user's current browser window from within an HTML page.
Pretty sure you can't do this cross browser and I'm positive you can't do it server side. However most browsers allow a full screen view which the user can get to.
In Internet Explorer and firefox the shortcut is F11. I know that's not the solution your looking for. However I'm pretty sure thats all there is.
I didn't see n0nick answer when I typed mine up. I agree with his answer I'm leaving mine in here for the F11 part.

Categories

Resources