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?
Related
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>
I do not want the webpage to reload if its already open, as this causes unnecessary data to be sent to the javascript application.
If the webpage is not open, I want it to be open.
If the webpage was open but the user used teh tab to load another webpage, i want a new webpage to open,.
If the webpage is open and still on the right url, I do not want any change, I do not want it to refresh.
However I can not seem to find a way to know if the url changed.
I can use cookies if i have to but would rather not. Any suggestions?
Thanks.
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.
So I recently implemented a chrome extension to grab images in an active tab and extract them to a popup for downloading. I would like to give users the option to view the popup window (including the extracted images) in a new Chrome tab.
However, since the popup is created dynamically by appending children to the body of my popup.html, I'm not sure how to pass the HTML for my popup to the new chrome tab.
I tried using chrome.tabs.create({url: chrome.extension.getURL('popup.html#window')});
as found at Open chrome extension in a new tab
but this doesn't seem to be working. Any suggestions?
I'm also developing a Chrome Extension that involves saving down a user's browser data.
Since each time an Extension opens a page (such as popup.html in your case) it opens a new instance of it, the pages and their relevant activity will be independent from each other.
In short you will have to implement some storage. The silver lining is it's pretty simple. Everything you need from manifest to example functions is here:
https://developer.chrome.com/extensions/storage
In your case what I'd imagine you'd want to do is this:
When you pass image urls to your popup page you also save them as items in an array in storage.
Then your pop up page can load in the array as the list to set downloading (or preview depending on use case).
Then either users can delete items from the array, or they are deleted programatically once downloaded.
I can't really be more specific without knowing exactly what your extension is trying to do or how it works, but hopefully that's enough to set you in the right direction.
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>