SitePoint Sponsor

User Tag List

Results 1 to 11 of 11

Thread: hows this work?

  1. #1
    Currently Occupied; Till Sunda Andrew-J2000's Avatar
    Join Date
    Aug 2001
    Location
    London
    Posts
    2,475
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    hows this work?

    can someone explain how this works?

    Code:
    dw = new Function("x", "document.write(x)");
    dw('<style type="text/css">');
    I also just saw this

    Code:
    if (getInnerText(n1.cells[c]) &lt; getInnerText(n2.cells[c]))
    is this valid?

  2. #2
    SitePoint Addict Caterwomtious's Avatar
    Join Date
    Dec 2001
    Posts
    222
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Part 2 would take a little research, but part 1 is just another way of writing a function. It means the same as:

    function dw(x)
    {
    document.write(x);
    }

    dw('<style type="text/css">');

  3. #3
    Currently Occupied; Till Sunda Andrew-J2000's Avatar
    Join Date
    Aug 2001
    Location
    London
    Posts
    2,475
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    ok thanks for that

    the second one has me confused lol

  4. #4
    That's Right. notepad_coder's Avatar
    Join Date
    Apr 2002
    Location
    Colorado
    Posts
    835
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    All it looks like to me is the function writes <style type="text/css"> out. But I'm might be wrong.

  5. #5
    Currently Occupied; Till Sunda Andrew-J2000's Avatar
    Join Date
    Aug 2001
    Location
    London
    Posts
    2,475
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I know that now, but what i dont get is this

    PHP Code:
    if (getInnerText(n1.cells[c]) &ltgetInnerText(n2.cells[c])) 
    &lt;

    I have a feeling i read it wrong and it was being parsed to document.write.

  6. #6
    What? Maelstrom's Avatar
    Join Date
    Oct 2001
    Location
    Whistler BC originally from Guelph Ontario
    Posts
    2,175
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Originally posted by Andrew-J2000
    I know that now, but what i dont get is this

    PHP Code:
    if (getInnerText(n1.cells[c]) &ltgetInnerText(n2.cells[c])) 
    &lt;

    I have a feeling i read it wrong and it was being parsed to document.write.
    If I remember correctly that is the DOM way of reading information from a certain cell within a table. It would be the same as

    document.getElementById('test').innerHTML

    except you don't have to label every cell with ids and you can navigate your way around the table in that method.
    Maelstrom Personal - Apparition Visions
    Development - PhP || Mysql || Zend || Devshed
    Unix - FreeBSD || FreeBsdForums || Man Pages
    They made me a sitepoint Mentor - Feel free to PM me or Email me and I will see if I can help.

  7. #7
    Currently Occupied; Till Sunda Andrew-J2000's Avatar
    Join Date
    Aug 2001
    Location
    London
    Posts
    2,475
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    so (&lt;) is valid then?

  8. #8
    What? Maelstrom's Avatar
    Join Date
    Oct 2001
    Location
    Whistler BC originally from Guelph Ontario
    Posts
    2,175
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Originally posted by Andrew-J2000
    so (&lt is valid then?
    As long as you have the ; at the end I believe it validates yes.
    Maelstrom Personal - Apparition Visions
    Development - PhP || Mysql || Zend || Devshed
    Unix - FreeBSD || FreeBsdForums || Man Pages
    They made me a sitepoint Mentor - Feel free to PM me or Email me and I will see if I can help.

  9. #9
    Currently Occupied; Till Sunda Andrew-J2000's Avatar
    Join Date
    Aug 2001
    Location
    London
    Posts
    2,475
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    How would i use this as i tested using it before and i got a syntax error?

  10. #10
    What? Maelstrom's Avatar
    Join Date
    Oct 2001
    Location
    Whistler BC originally from Guelph Ontario
    Posts
    2,175
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Originally posted by Andrew-J2000
    How would i use this as i tested using it before and i got a syntax error?
    Wow am I out of it. It is a greater than sign. Sorry bout that. I am sure that javascript will not read that right so you have to make it >

    Sorry bout that.
    Maelstrom Personal - Apparition Visions
    Development - PhP || Mysql || Zend || Devshed
    Unix - FreeBSD || FreeBsdForums || Man Pages
    They made me a sitepoint Mentor - Feel free to PM me or Email me and I will see if I can help.

  11. #11
    Currently Occupied; Till Sunda Andrew-J2000's Avatar
    Join Date
    Aug 2001
    Location
    London
    Posts
    2,475
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    hehe np. Well I read that code somewhere and all i can think is that i read it wrong lol, at first i thought it was a bitewise operator but then when i thought about it just didn't make sense so i guess its just me misreading the code.

    cheers for the help though


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
  •