Page 2 of 2 FirstFirst 12
Results 11 to 14 of 14

Thread: javascript not to open in new window

  1. #11
    Join Date
    Mar 2005
    Location
    SE PA USA
    Posts
    30,497
    Thanks
    82
    Thanked 3,449 Times in 3,410 Posts
    Blog Entries
    12

    Default

    Ah, yes, (my fault this time) not resetting the newContent variable, add red:

    Code:
    ;(function(){
    	var div, ft, trg;
    	if(document.getElementById('aanumbersresults')){div = document.getElementById('aanumbersresults');}
    	else {
    		div = document.createElement('div'); ft = document.getElementById('footer'); trg = ft.parentNode;
    		div.id = 'aanumbersresults';
    		trg.insertBefore(div, ft);
    	}
    	div.innerHTML = newContent;
    	newContent = "<div class=\"container margin-top-70 margin-bottom-90\"><div class=\"row margin-bottom-60\"><div class=\"col-md-12\">";
    })();
    }}
    Tested in the console and will work if implemented as suggested.

    However, I would also suggest a few other minor changes for cosmetic (layout), and ease of future editing. But let's get this part working first.
    Last edited by jscheuer1; 02-27-2018 at 03:18 AM. Reason: add info
    - John
    ________________________

    Show Additional Thanks: International Rescue Committee - Donate or: The Ocean Conservancy - Donate or: PayPal - Donate

  2. The Following User Says Thank You to jscheuer1 For This Useful Post:

    chechu (02-27-2018)

  3. #12
    Join Date
    Jul 2006
    Location
    Antwerp, Belgium (Europe)
    Posts
    903
    Thanks
    114
    Thanked 2 Times in 2 Posts

    Default

    Works like a charm, John.
    What cosmetics would you like to add/remove?
    Thanks!

  4. #13
    Join Date
    Mar 2005
    Location
    SE PA USA
    Posts
    30,497
    Thanks
    82
    Thanked 3,449 Times in 3,410 Posts
    Blog Entries
    12

    Default

    Well, just two (or three, depending how you count them) things. First of all, at the beginning, were we have, I'd add the highlighted:

    Code:
    // globale variabelen
    var newWindow;
    var newContent = "<div class=\"container margin-top-50 margin-bottom-90\"><div class=\"row margin-bottom-60\"><div class=\"col-md-12\">";
    var newContentBak = newContent;
    That way, we won't have to retype it later, so can change the added code as shown:

    Code:
    ;(function(){
    	var div, ft, trg;
    	if(document.getElementById('aanumbersresults')){div = document.getElementById('aanumbersresults');}
    	else {
    		div = document.createElement('div'); ft = document.getElementById('footer'); trg = ft.parentNode;
    		div.id = 'aanumbersresults';
    		trg.insertBefore(div, ft);
    	}
    	div.innerHTML = newContent;
        newContent = newContentBak;
    })();
    }}
    That will make it easier should you ever want to change the vertical spacing or any other characteristics of the result that are controlled there. You indicated before that you might. If you do, then go back to the beginning and make it (or try other changes if you prefer, or leave as is if you like, the main thing is it only needs to be changed in one place now, not two):

    Code:
    // globale variabelen
    var newWindow;
    var newContent = "<div class=\"container\" style='margin-top: -100px;'><div class=\"row\"><div class=\"col-md-12\">";
    var newContentBak = newContent;
    - John
    ________________________

    Show Additional Thanks: International Rescue Committee - Donate or: The Ocean Conservancy - Donate or: PayPal - Donate

  5. #14
    Join Date
    Jul 2006
    Location
    Antwerp, Belgium (Europe)
    Posts
    903
    Thanks
    114
    Thanked 2 Times in 2 Posts

Similar Threads

  1. javascript:window.open
    By Pinky in forum HTML
    Replies: 11
    Last Post: 08-29-2009, 08:54 PM
  2. Replies: 2
    Last Post: 03-14-2009, 05:32 PM
  3. Open javascript link in same window
    By weezle in forum JavaScript
    Replies: 2
    Last Post: 02-07-2009, 05:12 PM
  4. New window open in JavaScript
    By Neal in forum JavaScript
    Replies: 5
    Last Post: 03-12-2008, 04:21 AM
  5. window.open() :- javascript
    By manashi_130582 in forum JavaScript
    Replies: 3
    Last Post: 04-26-2006, 06:39 AM

Bookmarks

Posting Permissions

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