SitePoint Sponsor

User Tag List

Results 1 to 9 of 9
  1. #1
    SitePoint Enthusiast
    Join Date
    Oct 2002
    Posts
    26
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Unhappy A little window.open problem

    well here is my code

    <span class="text">
    <a onclick="window.open('photoshop/tutorial1.php' , 'tutorials' , 'width=100% , height=100% , scrollbars=auto, toolbar=no, status=no')" class="special">View this Tutorial</a> - <b>Rate/b> ehehehe
    </span>

    why wont it open the window as 100% and opens as 100pixels by 100 pixels. please help me

  2. #2
    SitePoint Wizard siteguru's Avatar
    Join Date
    Oct 2002
    Location
    Scotland
    Posts
    3,609
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)
    Because, IIRC, javascript only accepts absolute values for the window.open( ) function - the % is meaningless and is ignored. What you will have to do is get the screen width and height using javascript and document.write those values into your page.

    <span class="text">
    <script type="text/javascript">
    document.write ('<a onclick="window.open(\'photoshop/tutorial1.php\', \'tutorials\', \'width='+varWidth+',height='+varHeight+',scrollbars=auto,toolbar=no,status=no\')" class="special">View this Tutorial</a> - <b>Rate/b> ehehehe');
    </script>
    </span>

    Search for "javascript screen size" and you will find lots of resources on this subject.
    Last edited by siteguru; Oct 10, 2002 at 07:24.
    Ian Anderson
    www.siteguru.co.uk

  3. #3
    Web-coding NINJA! silver trophy beetle's Avatar
    Join Date
    Jul 2002
    Location
    Dallas, TX
    Posts
    2,900
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Percentages aren't allowed for the width/height with the window.open method. Instead, those figures need to be calculated per the screen size...
    Code:
    function popWin(nUrl) {
    var w = screen.availWidth;
    var h = screen.availHeight;
    var features = 'width = '+w+', height='+h+', scrollbars=yes, toolbar=no, status=no';
    window.open(nUrl, 'tutorials', features);
    }
    And to make sure your links properly degrade and are search engine friendly, I'd do it like this...
    Code:
    <a href="photoshop/tutorial1.php" onclick="popWin(this.href);return false;" class="special">View this Tutorial</a>
    You can adjust the function to have more parameters for more flexibility, if you need it. Otherwise, you can just leave the other data hard-coded in the function.

    Oh, and you may notice that I changed 'scrollbars=auto' to 'scrollbars=yes'. auto is a CSS value for the overflow property, and not a valid value here. Scrollbars on a window by their nature behave as auto does for overflow
    beetle a.k.a. Peter Bailey
    blogs: php | prophp | security | design | zen | software
    refs: dhtml | gecko | prototype | phpdocs | unicode | charsets
    tools: ide | ftp | regex | ffdev




  4. #4
    SitePoint Enthusiast
    Join Date
    Oct 2002
    Posts
    26
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    thanks dude. i undestand but it didnt work says problem with varWidth

  5. #5
    SitePoint Enthusiast
    Join Date
    Oct 2002
    Posts
    26
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    omg omg omg beetle. ur a genius. THANSK THANKS THANKs. and it looks so cool too. ur a js pro i bet. oooooo

    mwahaha. i am unstopable now. yes yes yes


    thjanks a million

  6. #6
    Web-coding NINJA! silver trophy beetle's Avatar
    Join Date
    Jul 2002
    Location
    Dallas, TX
    Posts
    2,900
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thanks, I'd like to think I'm pretty good. Just a couple weeks ago I got a Master-Level score (4.21) in DHTML from brainbench.com....

    Worth anything? dunno...but I like having it
    beetle a.k.a. Peter Bailey
    blogs: php | prophp | security | design | zen | software
    refs: dhtml | gecko | prototype | phpdocs | unicode | charsets
    tools: ide | ftp | regex | ffdev




  7. #7
    SitePoint Enthusiast
    Join Date
    Oct 2002
    Posts
    26
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    cool dude. i went to ur site. BRILLIANT. except i cant click the buttons and ewhen i do they do nothing

    however its amazing how i dont see any code except the contentlayer. amzing dude. please do u have msn, or aim??

  8. #8
    Web-coding NINJA! silver trophy beetle's Avatar
    Join Date
    Jul 2002
    Location
    Dallas, TX
    Posts
    2,900
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Ya, my current site is busted (happened when I change servers...gremlins in the cables or something...) I'm making a new one anyways...

    I have ICQ here at the office, used to have Trillian running with MSN and AIM too but now we got a proxy server that Trillian can't negotiate around...so just ICQ is working.
    beetle a.k.a. Peter Bailey
    blogs: php | prophp | security | design | zen | software
    refs: dhtml | gecko | prototype | phpdocs | unicode | charsets
    tools: ide | ftp | regex | ffdev




  9. #9
    SitePoint Enthusiast
    Join Date
    Oct 2002
    Posts
    26
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    ok. could u maybe send me an email

    mail@vrumchev.com till i get meself icq


    thanks man


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
  •