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 3 of 3
  1. #1
    New to the CF scene
    Join Date
    May 2009
    Posts
    4
    Thanks
    0
    Thanked 0 Times in 0 Posts

    How to make this bookmarklet open in new window

    I need this bookmarklet (below) to open in a new window and display the info there. It needs to work in both FF and IE. It would be in one line in the bookmarklet but I expanded it for readability. It should work against our site:www.mysanantonio.com
    Code:
    javascript:
    var adBookmarkletData=[];
      adBookmarkletData.push('<html><head><title>MYSA Yahoo! APT Debugger</title></head><body><center><div style=\"background:#ccc;color:#000;width:350px;text-align:left;padding:15px;border:2px #000;\">');
      adBookmarkletData.push('<b>MYSA Yahoo! APT Debugger:</b><br /><hr />');
      adBookmarkletData.push('<b>URL:</b> '+document.location.href+'<br />');
      adBookmarkletData.push('<b>Pub ID:</b> '+window.yld_mgr.pub_id+'<br />');
      adBookmarkletData.push('<b>Site Name:</b> '+window.yld_mgr.site_name+'<br />');
      adBookmarkletData.push('<b>Content Topic ID List:</b> '+window.yld_mgr.content_topic_id_list+'<br />');
      adBookmarkletData.push('<b>Site Section Name List:</b> '+window.yld_mgr.site_section_name_list+'<br />');
      for(i in window.yld_mgr.slots){
        adBookmarkletData.push('<b>AD:</b> ('+i+') <b>Category:</b>('+window.yld_mgr.slots[i].cstm_content_cat_list+')<br />');
      };
      adBookmarkletData.push('</div></center></body></html>');
      function createAptDebugger(){
        for (i in adBookmarkletData){document.write(adBookmarkletData[i]);}
      };
      void(createAptDebugger());
    This had been suggested and I tried it but it only opens an empty window in IE and an empty tab in FF. I need it to open a new window in both:
    This did not work:
    Code:
    var adBookmarkletData=[
    '<html><head><title>MYSA Yahoo! APT Debugger</title></head><body><center><div style=\"background:#ccc;color:#000;width:350px;text-align:left;padding:15px;border:2px #000;\">',
    '<b>MYSA Yahoo! APT Debugger:</b><br /><hr />',
    '<b>URL:</b> '+document.location.href+'<br />',
    '<b>Pub ID:</b> '+window.yld_mgr.pub_id+'<br />',
    '<b>Site Name:</b> '+window.yld_mgr.site_name+'<br />',
    '<b>Content Topic ID List:</b> '+window.yld_mgr.content_topic_id_list+'<br />',
    '<b>Site Section Name List:</b> '+window.yld_mgr.site_section_name_list+'<br />'];
      for(i in window.yld_mgr.slots){
        adBookmarkletData.push('<b>AD:</b> ('+i+') <b>Category:</b>('+window.yld_mgr.slots[i].cstm_content_cat_list+')<br />');
      };
      adBookmarkletData.push('</div></center></body></html>');
      function createAptDebugger(){
        var pu=window.open("");
        pu.onload=function(){
          pu.document.write(adBookmarkletData.join(""));
        }
     };
      void(createAptDebugger());
    I've been trying different things but no joy. Thank in advance for looking at this,
    Regards,

  • #2
    Senior Coder
    Join Date
    Jun 2002
    Posts
    1,404
    Thanks
    2
    Thanked 32 Times in 32 Posts
    Try this:

    Code:
    function createAptDebugger(){
        pu=window.open("javascript:adBookmarkletData.join('')", "", "");
     };
      void(createAptDebugger());
    [untested]

    You can add window properties in the 3rd argument to open().
    By the time open() returns, the window is already open and, with only a blank document to load, it's probably too late to set the onload handler. A javascript: url should load the string.

  • #3
    New to the CF scene
    Join Date
    May 2009
    Posts
    4
    Thanks
    0
    Thanked 0 Times in 0 Posts
    The inspiration for this was from a bookmarklet that actually sources another page.

    It looks like this:
    Code:
    javascript:
    void(window.open(%22%22,%22stats_debugger%22,%22width=600,height=600,location=0,menubar=0,status=1,toolbar=0,resizable=1,scrollbars=1%22).document.write(%22<script language=\%22JavaScript\%22 src=\%22https://sitecatalyst.omniture.com/sc_tools/stats_debugger.html\%22></%22+%22script>%22 + %22<script language=\%22JavaScript\%22>window.focus();</script>%22));
    I may try that approach too. The reason I did not do it was that the method I used seemed so close and I thought it was a matter of just getting it to open in a new browser. I am still not clear on the mechanics of opening a new window or tab that actually has code from the previous one.???

    BTW I am grateful for your response.
    Last edited by SayItAintSo; 05-22-2009 at 04:59 PM. Reason: Thanks


  •  

    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
    •