Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 12 of 12
  1. #1
    Regular Coder
    Join Date
    Sep 2011
    Posts
    348
    Thanks
    39
    Thanked 0 Times in 0 Posts

    FOR LOOP problem in JavaScript! HELP!

    What I am trying to do is when a user click on an image button, 10 new windows will oppen. So, I created a For Loop function for that. Here is my code below:

    function clickk () {
    for (i=0; i<=10, i++) {
    window.open('annoying1.html','Annoying LOL','width=900, height=900')
    ;}
    }

    However, the window does open but not 10 times. Can you help me? Thank you...

  • #2
    Supreme Master coder! Philip M's Avatar
    Join Date
    Jun 2002
    Location
    London, England
    Posts
    17,986
    Thanks
    203
    Thanked 2,536 Times in 2,514 Posts
    You are opening the same window 10 times.

    You must give each one a different name.

    All advice is supplied packaged by intellectual weight, and not by volume. Contents may settle slightly in transit.

    All the code given in this post has been tested and is intended to address the question asked.
    Unless stated otherwise it is not just a demonstration.

  • #3
    Regular Coder
    Join Date
    Sep 2011
    Posts
    348
    Thanks
    39
    Thanked 0 Times in 0 Posts
    When I do only:

    window.open('annoying1.html');

    it is working, but I do not want the menu bar to appear, and when i do tht, it is not working. only when it is having the URL like above, it is working.

  • #4
    Senior Coder Logic Ali's Avatar
    Join Date
    Sep 2010
    Location
    London
    Posts
    1,028
    Thanks
    0
    Thanked 207 Times in 202 Posts
    Another problem is that IE won't allow a space in a window name.
    If your browser allows opening multiple windows from one commend, this may work:
    Code:
    function clickk () 
    {
      for ( var i=1; i<=10, i++ ) 
        window.open('annoying1.html', 'Annoying_LOL('+i+')', 'width=900, height=900');
    }

  • #5
    Supreme Master coder! Old Pedant's Avatar
    Join Date
    Feb 2009
    Posts
    25,447
    Thanks
    76
    Thanked 4,372 Times in 4,337 Posts
    I don't think IE will allow ( ) in window names, either. But I don't see why those need to be there, at all.

    Why not simply:
    Code:
    function clickk () 
    {
      for ( var i=1; i<=10, i++ ) 
        window.open('annoying1.html', 'Annoying_LOL'+i, 'width=900, height=900');
    }
    An optimist sees the glass as half full.
    A pessimist sees the glass as half empty.
    A realist drinks it no matter how much there is.

  • #6
    Regular Coder
    Join Date
    Sep 2011
    Posts
    348
    Thanks
    39
    Thanked 0 Times in 0 Posts
    Guys I got the answer... here it is:

    var openWind = new Array();
    function clickk () {
    for (i=1; i<=15; i++) {
    openWind[i] = window.open('annoying.html','window'+i,'menubar=no')
    ;}
    }

    thank you

  • #7
    Supreme Master coder! Philip M's Avatar
    Join Date
    Jun 2002
    Location
    London, England
    Posts
    17,986
    Thanks
    203
    Thanked 2,536 Times in 2,514 Posts
    I expect that you realise that sort of thing will guarantee that people will visit your site once only.

    All the code given in this post has been tested and is intended to address the question asked.
    Unless stated otherwise it is not just a demonstration.

  • #8
    Regular Coder
    Join Date
    Sep 2011
    Posts
    348
    Thanks
    39
    Thanked 0 Times in 0 Posts
    lol lol lol
    Last edited by angelali; 12-19-2011 at 08:20 PM.

  • #9
    Supreme Master coder! Old Pedant's Avatar
    Join Date
    Feb 2009
    Posts
    25,447
    Thanks
    76
    Thanked 4,372 Times in 4,337 Posts
    Well, actually, it might guarantee that an annoyed hacker will set up a robot to hit his site millions of times per day and cause his server to crash. So if he is on a shared host, you can bet his host will kick him off right after that happens the first time.
    An optimist sees the glass as half full.
    A pessimist sees the glass as half empty.
    A realist drinks it no matter how much there is.

  • #10
    Regular Coder
    Join Date
    Sep 2011
    Posts
    348
    Thanks
    39
    Thanked 0 Times in 0 Posts
    I am making the most annoying website in the world... it is for fun... It has already finished...if you want visit it...but do read the conditions before pressing Enter.. I will give you the link now...the website's name is Most Annoying Website. So what hacker are you talking when everyone knows it is for annoying people and for fun? I will not care my server, will the hacker hack popular paid hosting like Bluehost, dreamhost and so on when he knows the website is for fun and based only to annoy people? Know what you are talking man! It is not a normal website like others... on Most Annoying Website, you get pawned and it is for fun.. you take the risk to click on the Enter button...and I will not care if people do not read the conditions!
    Last edited by angelali; 12-20-2011 at 07:39 AM.

  • #11
    Supreme Master coder! Philip M's Avatar
    Join Date
    Jun 2002
    Location
    London, England
    Posts
    17,986
    Thanks
    203
    Thanked 2,536 Times in 2,514 Posts
    Quote Originally Posted by angelali View Post
    I am making the most annoying website in the world... it is for fun... It has already finished
    Have you visited your doctor recently? Your idea of fun is a bit strange, especially as you can only snigger at the general thought of annoying your (unknown) visitors. People who massively enjoy annoying others are in need of help. Another suggestion is to grow up.

    http://emedicine.medscape.com/article/918095-overview
    Last edited by Philip M; 12-20-2011 at 08:18 AM.

    All the code given in this post has been tested and is intended to address the question asked.
    Unless stated otherwise it is not just a demonstration.

  • #12
    Regular Coder
    Join Date
    Sep 2011
    Posts
    348
    Thanks
    39
    Thanked 0 Times in 0 Posts
    Do you know websites like Red Dot, takethisllolipop and so on? Why you dont say they are retards? If you dont agree with my idea...don't say it is retard!


  •  

    Tags for this Thread

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •