Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Can I submit multiple links at once??

Status
Not open for further replies.
Define submit? Do you want to have iframes load these sites at the same time with a search term?

Do you simply want to open them in a separate window?

What exactly do you want to do?





----------------------------------
Phil AKA Vacunita
----------------------------------
Ignorance is not necessarily Bliss, case in point:
Unknown has caused an Unknown Error on Unknown and must be shutdown to prevent damage to Unknown.

Behind the Web, Tips and Tricks for Web Development.
 
Hi

hiyatran said:
I check all over the web and can't find any examples anywhere.
Actually you found it. The answer is, not possible.

However you can submit the same [tt]form[/tt] many times if the [tt]target[/tt] is not [tt]_self[/tt], [tt]_parent[/tt] or [tt]_top[/tt]. For that you can use [tt]iframe[/tt]s.

This type of tasks are better accomplished with server-side scripting, because client-side scripts are subject of same origin restrictions. But depending on your task, you could live with it.


Feherke.
 
I sort of got it working, here's the code:

Code:
function addtext() {
   var openURL = new Array("google.com","yahoo.com","msn.com"); 
   for(var i=0;i<=openURL.length;i++){    
      if (openURL[i].substr(0,4) != 'http'){        
         openURL[i] = '[URL unfurl="true"]http://'+openURL[/URL][i];    
      }        
      window.open(openURL[i]);
      [B]self.close();[/B]   
   }
}

but the function self.close() or window.close() does NOT work
any ideas???
thanks

 
Hi

hiyatran said:
but the function self.close() or window.close() does NOT work
Do you realize there you are trying to close the current window in a loop ? So the [tt]for[/tt]'s block will be executed only once, as the document would be disposed long before the second execution. Anyway, this only explains why that will never work correctly.

The explanation for why it not seems to work, is that JavaScript is allowed to close only windows opened by JavaScript. And the window in which your above quoted code runs, was probably not opened by JavaScript.

You probably would like something like this :
Code:
[b]function[/b] [COLOR=darkgoldenrod]addtext[/color][teal]()[/teal] [teal]{[/teal]
   [b]var[/b] openURL [teal]=[/teal] [b]new[/b] [COLOR=darkgoldenrod]Array[/color][teal]([/teal][green][i]"google.com"[/i][/green][teal],[/teal][green][i]"yahoo.com"[/i][/green][teal],[/teal][green][i]"msn.com"[/i][/green][teal]);[/teal]
   [b]for[/b][teal]([/teal][b]var[/b] i[teal]=[/teal][purple]0[/purple][teal];[/teal]i[teal]<=[/teal]openURL[teal].[/teal]length[teal];[/teal]i[teal]++)[/teal][teal]{[/teal]    
      [b]if[/b] [teal]([/teal]openURL[teal][[/teal]i[teal]].[/teal][COLOR=darkgoldenrod]substr[/color][teal]([/teal][purple]0[/purple][teal],[/teal][purple]4[/purple][teal])[/teal] [teal]!=[/teal] [green][i]'http'[/i][/green][teal])[/teal][teal]{[/teal]        
         openURL[teal][[/teal]i[teal]][/teal] [teal]=[/teal] [green][i]'[URL unfurl="true"]http://'[/URL][/i][/green][teal]+[/teal]openURL[teal][[/teal]i[teal]];[/teal]    
      [teal]}[/teal]        
      [highlight][b]var[/b] newwin[teal]=[/teal][/highlight]window[teal].[/teal][COLOR=darkgoldenrod]open[/color][teal]([/teal]openURL[teal][[/teal]i[teal]]);[/teal]
      [highlight]newwin[/highlight][teal].[/teal][COLOR=darkgoldenrod]close[/color][teal]();[/teal]   
   [teal]}[/teal]
[teal]}[/teal]
However, there would be no time for those URLs to load before closing the window. Scheduling the closing with [tt]setTimeout()[/tt] would solve it, but there is no way to find out how long to wait before closing.



Feherke.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top