SitePoint Sponsor

User Tag List

Results 1 to 3 of 3
  1. #1
    SitePoint Member
    Join Date
    Jul 2003
    Location
    Sydney Australia
    Posts
    2
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    new browser window with size, toolbars

    I have found the javascript (external.js) from this website and would like to modify it to add width,height and toolbars to it, but when I have tried it broke the script, and didn't work at all.

    Current script:
    function externalLinks() {
    if (!document.getElementsByTagName) return;
    var anchors = document.getElementsByTagName("a");
    for (var i=0; i<anchors.length; i++) {
    var anchor = anchors[i];
    if (anchor.getAttribute("href") &&
    anchor.getAttribute("rel") == "external")
    anchor.target = "_blank";
    }
    }
    window.onload = externalLinks;

    I would like to add the following:
    'toolbar=yes,scrollbars=yes,width=550,height=550'

    Any suggestion on how this is possible, and where it needs to be would be appreicated. I cannot use it in the html, since it will constantly be updated, and therefore means I would have to rebuild each link.

    Tom Hatfield

  2. #2
    SitePoint Member
    Join Date
    Jul 2003
    Location
    germany
    Posts
    16
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    try this one....

    function customize(form) {
    var address = document.form1.url.value;
    var op_tool = (document.form1.tool.checked== true) ? 1 : 0;
    var op_loc_box = (document.form1.loc_box.checked == true) ? 1 : 0;
    var op_dir = (document.form1.dir.checked == true) ? 1 : 0;
    var op_stat = (document.form1.stat.checked == true) ? 1 : 0;
    var op_menu = (document.form1.menu.checked == true) ? 1 : 0;
    var op_scroll = (document.form1.scroll.checked == true) ? 1 : 0;
    var op_resize = (document.form1.resize.checked == true) ? 1 : 0;
    var op_wid = document.form1.wid.value;
    var op_heigh = document.form1.heigh.value;
    var option = "toolbar=" + op_tool + ",location=" + op_loc_box + ",directories="
    + op_dir + ",status=" + op_stat
    + ",menubar=" + op_menu + ",scrollbars="

    + op_scroll + ",resizeable=" + op_resize
    + ",width="
    + op_wid + ",height=" + op_heigh;
    var win3 = window.open("", "what_I_want", option);
    var win4 = window.open(address, "what_I_want");
    }
    function clear(form){
    document.form1.wid.value="";
    document.form1.heigh.value="";
    }

    </SCRIPT>

    function customize(form) {
    var address = document.form1.url.value;
    var op_tool = (document.form1.tool.checked== true) ? 1 : 0;
    var op_loc_box = (document.form1.loc_box.checked == true) ? 1 : 0;
    var op_dir = (document.form1.dir.checked == true) ? 1 : 0;
    var op_stat = (document.form1.stat.checked == true) ? 1 : 0;
    var op_menu = (document.form1.menu.checked == true) ? 1 : 0;
    var op_scroll = (document.form1.scroll.checked == true) ? 1 : 0;
    var op_resize = (document.form1.resize.checked == true) ? 1 : 0;
    var op_wid = document.form1.wid.value;
    var op_heigh = document.form1.heigh.value;
    var option = "toolbar=" + op_tool + ",location=" + op_loc_box + ",directories="
    + op_dir + ",status=" + op_stat
    + ",menubar=" + op_menu + ",scrollbars="

    + op_scroll + ",resizeable=" + op_resize
    + ",width="
    + op_wid + ",height=" + op_heigh;
    var win3 = window.open("", "what_I_want", option);
    var win4 = window.open(address, "what_I_want");
    }
    function clear(form){
    document.form1.wid.value="";
    document.form1.heigh.value="";
    }
    // done hiding -->
    </SCRIPT>

    let me know if it works

  3. #3
    SitePoint Member
    Join Date
    Jul 2003
    Location
    Sydney Australia
    Posts
    2
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by zuzupus
    try this one....
    let me know if it works
    I tried it, both in the html page, and as a javascript file, could not get it to work with either one, maybe I am missing some finer point in how to use it.

    The test page I am working on:
    http://www.tomhatfield.net/test/adelaide1.htm

    has four links:
    the first one opens centered, with the sizes I would like to use, but it done within the linked code

    the second one just opens a new broswer window, called from the linked code

    the third one is useing the rel=external.js file

    the forth one is using linked code.

    What I need is for the third one to use the external.js file to open a new browser window in the size and with toolbars like the fourth link. Because the pages will be updated from an external file so often I don't want to have to add the code to each link, but want it to call the javascript file.


    Tom


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
  •