How to open multiple tabs from one HTML file [closed]

谁都会走 提交于 2019-12-09 07:14:16

问题


I work on many computers, which means they use default browser settings (There is no point in changing browser settings, because I will have to do it every time). I need to make an HTML file which will open a specific list of desired pages (think of this as opening all my bookmarks). For example I visit facebook, yahoo, and stackoverflow. I want to click that HTML file, and it will open these 3 sites on the same window (different tabs).

Also would functionality like automatic login on all the sites be easy for implementation?

Attention: Focus on a "portable" solution. Assume that you only have default browser settings. No setting up servers, changing browser settings and things like that. Imagine that you have 200 computers and you can sit on any one of them. You have only a flash-drive with some files on it. I want to click an HTML file, or some script or whatever, so that these pages open in my browser, without triggering the popup blocker.


回答1:


How about using a batch file? I just tried it in Windows 7 with Chrome and it opened all 3 URLs in the same window.

Make a plain text file with Notepad called file-name.bat. Then add this code:

start chrome.exe http://www.google.com
start chrome.exe http://www.yahoo.com
start chrome.exe http://www.microsoft.com

All you should have to do is double click it to run it. You may get a security warning (I didn't).

You could check this out too: Batch file for opening one of a list of URLs




回答2:


<script type='text/javascript'>
(function(){
  //add this line for each website you want to open
  window.open("http://www.facebook.com/",'');
})()
</script>

there are more answers to this question that work here




回答3:


Try this example. I hope this something like this is what you want. About popup blocked you have to configure your browser to allow popup opened from this page. The easiest that I know to bypass the popup blocker is put this page inside local server like apache and set your browser to allow popup from localhost.

<html>
<script>
function openLinks(){
links = document.getElementsByTagName('a');

 for (i = 0; i < links.length;i++){ 
   window.open(links[i].getAttribute('href'),'_blank');
   window.focus();
 }
}
</script>

<body onload="openLinks()">

<a href="http://google.com">google</a>
<a href="http://stackoverflow.com">stackoverflow</a>
<a href="http://facebook.com">facebook</a>
<!-- add other link -->

</body>
</html>



回答4:


This functionality is built into Chrome. If you don't have to use an HTML file, try just setting your Startup Pages in Chrome's settings. You can add as many pages as you want.

http://support.google.com/chrome/bin/answer.py?hl=en&answer=95421




回答5:


You could just add window.open(adress) for every page you want to open, or you could use a for loop if you want to open 1 page a specific number of times.



来源:https://stackoverflow.com/questions/14371285/how-to-open-multiple-tabs-from-one-html-file

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!