clip in Opera

Discussion in 'Javascript' started by roman@nomail, Sep 10, 2003.

  1. roman@nomail

    roman@nomail Guest

    Hello,

    I've just downloaded and installed Opera711, good browser. Most of my
    scripts work just fine, except the ones that use "clip" property. Opera
    docs say that it's supported but I can't get it to work. It seems that
    clip is some kind of object (some kind of rect?) but I'm unable to read
    it's properties, only
    methods. It has only one method "replace". Can you tell me what's going
    on there? And why can't I read properties of objects with the function
    below?
    ----------------------------------------
    <HTML><HEAD><TITLE></TITLE>
    <script type="text/javascript">
    function getClip(o){
    var c = o.style.clip;
    //document.zz.qq.value = objProps(c, 'o');
    //document.zz.qq.value = objProps(o, 'o');
    document.zz.qq.value = objProps(o.style, 'o');
    }
    function objProps(obj, name){
    var str = "";
    for (var i in obj)
    str += name + '.' +i+ '=' +obj+ '\n';
    return str;
    }
    function s(){
    this.h = "k";
    }
    </script>
    </HEAD><BODY>

    <DIV ONCLICK="getClip(this)"
    STYLE="position:absolute; top:0; left:0; width:100; height:50">Get
    Clip</DIV>

    <FORM NAME="zz" ACTION="" METHOD="">
    <TEXTAREA NAME="qq" COLS=65 ROWS=15></TEXTAREA>
    </FORM>
    </BODY></HTML>
    -----------------------------------
    TIA,
    Roman
    roman@nomail, Sep 10, 2003
    #1
    1. Advertising

  2. <roman@nomail> schreef in bericht
    news:...
    > Hello,
    >
    > I've just downloaded and installed Opera711, good browser. Most of my
    > scripts work just fine, except the ones that use "clip" property. Opera
    > docs say that it's supported but I can't get it to work. It seems that
    > clip is some kind of object (some kind of rect?) but I'm unable to read
    > it's properties, only
    > methods. It has only one method "replace". Can you tell me what's going
    > on there? And why can't I read properties of objects with the function
    > below?


    There isn't such thing as a default clip property, so you will have to set
    it if you want to use it:

    function getClip(o){
    var c = o.style.clip;
    if (c) alert(c); else alert('Not set');
    }
    ....
    <DIV ONCLICK="getClip(this)"
    STYLE="position:absolute; top:0; left:0; width:100; height:50;
    clip:rect(auto,auto,auto,auto)">Get
    Clip</DIV>


    JW
    Janwillem Borleffs, Sep 10, 2003
    #2
    1. Advertising

  3. roman@nomail

    DU Guest

    roman@nomail wrote:

    > Hello,
    >
    > I've just downloaded and installed Opera711, good browser. Most of my
    > scripts work just fine, except the ones that use "clip" property. Opera
    > docs say that it's supported but I can't get it to work.


    There are a few bugs. One well known in Opera 7.x is that the background
    (image, color) is not clipped, only content.

    It seems that
    > clip is some kind of object (some kind of rect?) but I'm unable to read
    > it's properties, only
    > methods.


    clip is a property. The only shape supported is rect.

    It has only one method "replace".

    ?

    Can you tell me what's going
    > on there? And why can't I read properties of objects with the function
    > below?
    > ----------------------------------------
    > <HTML><HEAD><TITLE></TITLE>
    > <script type="text/javascript">
    > function getClip(o){
    > var c = o.style.clip;
    > //document.zz.qq.value = objProps(c, 'o');
    > //document.zz.qq.value = objProps(o, 'o');
    > document.zz.qq.value = objProps(o.style, 'o');


    Opera 7.20 beta now supports getComputedStyle and getComputedValue.
    Your getClip function is not best I think. I would have been using
    currentStyle for IE instead of style... if you want to get the default
    css declarations of existing elements.

    > }
    > function objProps(obj, name){
    > var str = "";
    > for (var i in obj)
    > str += name + '.' +i+ '=' +obj+ '\n';
    > return str;
    > }
    > function s(){
    > this.h = "k";
    > }
    > </script>
    > </HEAD><BODY>
    >
    > <DIV ONCLICK="getClip(this)"
    > STYLE="position:absolute; top:0; left:0; width:100; height:50">Get
    > Clip</DIV>
    >


    Invalid CSS code.
    "a unit must be specified for length values"
    http://www.w3.org/TR/CSS2/syndata.html#parsing-errors

    " The format of a length value (denoted by <length> in this
    specification) is an optional sign character ('+' or '-', with '+' being
    the default) immediately followed by a <number> (with or without a
    decimal point) immediately followed by a unit identifier (e.g., px, deg,
    etc.)."
    http://www.w3.org/TR/CSS2/syndata.html#value-def-length

    Your getClip function should be coded in a way that it should return
    rect(auto auto auto auto)
    or
    rect(auto,auto,auto,auto)
    in any DOM2 and CSS2 compliant browser.

    > <FORM NAME="zz" ACTION="" METHOD="">
    > <TEXTAREA NAME="qq" COLS=65 ROWS=15></TEXTAREA>


    It's always better to quote attribute values as it speeds up a bit
    parsing and rendering and it avoids errors of all kinds in all sorts of
    situations.

    http://www.htmlhelp.com/faq/html/basics.html#quotes
    http://www.html-faq.com/htmlvalidation/?quoteattributes
    Why attribute values should always be quoted in HTML
    http://www.cs.tut.fi/~jkorpela/qattr.html

    DU
    --
    Javascript and Browser bugs:
    http://www10.brinkster.com/doctorunclear/
    - Resources, help and tips for Netscape 7.x users and Composer
    - Interactive demos on Popup windows, music (audio/midi) in Netscape 7.x
    http://www10.brinkster.com/doctorunclear/Netscape7/Netscape7Section.html
    DU, Sep 10, 2003
    #3
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Ben
    Replies:
    2
    Views:
    2,325
    Kevin Spencer
    Sep 13, 2005
  2. romain

    Clip interface...

    romain, Aug 12, 2003, in forum: Java
    Replies:
    1
    Views:
    728
    Knute Johnson
    Aug 13, 2003
  3. Oracle3001
    Replies:
    0
    Views:
    371
    Oracle3001
    Oct 27, 2003
  4. Ralph
    Replies:
    0
    Views:
    888
    Ralph
    Jan 18, 2004
  5. Bob
    Replies:
    24
    Views:
    1,541
Loading...

Share This Page