Results 1 to 15 of 15

Thread: two quick questions

  1. #1

    Thread Starter
    transcendental analytic kedaman's Avatar
    Join Date
    Mar 2000
    Location
    0x002F2EA8
    Posts
    7,221

    two quick questions

    1. Is there any limit to how many div tags you can nest, if not would it affect performance to make a list by nesting div tags?

    2. Is there a performance issue using innerhtml to update an entire page as long as its stored in javascript? Any other way of just updating a small portion of a div tag?
    Use
    writing software in C++ is like driving rivets into steel beam with a toothpick.
    writing haskell makes your life easier:
    reverse (p (6*9)) where p x|x==0=""|True=chr (48+z): p y where (y,z)=divMod x 13
    To throw away OOP for low level languages is myopia, to keep OOP is hyperopia. To throw away OOP for a high level language is insight.

  2. #2

    Thread Starter
    transcendental analytic kedaman's Avatar
    Join Date
    Mar 2000
    Location
    0x002F2EA8
    Posts
    7,221
    another question, is it possible to make a link open a page when javascript is not activated, while doing something else when it is?
    Use
    writing software in C++ is like driving rivets into steel beam with a toothpick.
    writing haskell makes your life easier:
    reverse (p (6*9)) where p x|x==0=""|True=chr (48+z): p y where (y,z)=divMod x 13
    To throw away OOP for low level languages is myopia, to keep OOP is hyperopia. To throw away OOP for a high level language is insight.

  3. #3
    The Devil crptcblade's Avatar
    Join Date
    Aug 2000
    Location
    Quetzalshacatenango
    Posts
    9,091
    Well, there is the <noscript> tag to use when a browser doesn't support scripting. I don't know if that helps or not.
    Laugh, and the world laughs with you. Cry, and you just water down your vodka.


    Take credit, not responsibility

  4. #4
    I'm about to be a PowerPoster! mendhak's Avatar
    Join Date
    Feb 2002
    Location
    Ulaan Baator GooGoo: Frog
    Posts
    38,170

    Re: two quick questions

    Originally posted by kedaman
    1. Is there any limit to how many div tags you can nest, if not would it affect performance to make a list by nesting div tags?

    2. Is there a performance issue using innerhtml to update an entire page as long as its stored in javascript? Any other way of just updating a small portion of a div tag?
    1. No, it doesn't affect performance too much, and there's no limit. What would be your reason for using <div> instead of <ul> or <ol> for a list?

    2. That isn't really reccommended. It gets too cumbersome... what exactly are you trying to update in your div tag?

    another question, is it possible to make a link open a page when javascript is not activated, while doing something else when it is?
    You can't actually make a page open up if javascript isn't activated. What you can do, though, is put a sniffer on a page before this page, so that if javascript is activated, it goes to your desired page, otherwise, you display some other page instead.

    Or use the <noscript> tag, in which you can put HTML tags.

  5. #5
    Kitten CornedBee's Avatar
    Join Date
    Aug 2001
    Location
    In a microchip!
    Posts
    11,594
    Second question: yes, it is possible:
    Code:
    <a href="url" target="_blank" onclick="return doYourStuff()">...</a>
    doYourStuff must return false.
    All the buzzt
    CornedBee

    "Writing specifications is like writing a novel. Writing code is like writing poetry."
    - Anonymous, published by Raymond Chen

    Don't PM me with your problems, I scan most of the forums daily. If you do PM me, I will not answer your question.

  6. #6

    Thread Starter
    transcendental analytic kedaman's Avatar
    Join Date
    Mar 2000
    Location
    0x002F2EA8
    Posts
    7,221
    Thanks for all the answers
    mendhak, if i have a lot of text, in a div tag, wouldn't it be better performancewise if i just updated a nested div tag with less text?
    thanks CB for the elegant solution
    Use
    writing software in C++ is like driving rivets into steel beam with a toothpick.
    writing haskell makes your life easier:
    reverse (p (6*9)) where p x|x==0=""|True=chr (48+z): p y where (y,z)=divMod x 13
    To throw away OOP for low level languages is myopia, to keep OOP is hyperopia. To throw away OOP for a high level language is insight.

  7. #7
    I'm about to be a PowerPoster! mendhak's Avatar
    Join Date
    Feb 2002
    Location
    Ulaan Baator GooGoo: Frog
    Posts
    38,170
    Well, yeah, you could do that.

    By the way, can you show how you are doing the update of that DIV tag?

    Although I don't know the full details of your page, an alternative to what you're trying is to have two DIVs, (div1 and div2), with div2 hidden. When desired, you simply hide div1 and show div2.

    IF that's similar to what you're trying, then what I just suggested is better, performance-wise.

    Otherwise, you ought to go ahead with your "update" idea, which you really should show me... by update, are you referring to rewriting with javascript's document.write() ?

  8. #8

    Thread Starter
    transcendental analytic kedaman's Avatar
    Join Date
    Mar 2000
    Location
    0x002F2EA8
    Posts
    7,221
    well, you could check out the page in my sig, the one that used to be about squirrel.
    I'm having javascript files loaded dynamically to update the page instead of having everything loaded from start.
    Btw how do i jump to a certain div tag, in the script?
    Use
    writing software in C++ is like driving rivets into steel beam with a toothpick.
    writing haskell makes your life easier:
    reverse (p (6*9)) where p x|x==0=""|True=chr (48+z): p y where (y,z)=divMod x 13
    To throw away OOP for low level languages is myopia, to keep OOP is hyperopia. To throw away OOP for a high level language is insight.

  9. #9
    Kitten CornedBee's Avatar
    Join Date
    Aug 2001
    Location
    In a microchip!
    Posts
    11,594
    What do you mean, jump to?

    To get the div tag for manipulation, give it an id property and use document.getElementById(string)
    All the buzzt
    CornedBee

    "Writing specifications is like writing a novel. Writing code is like writing poetry."
    - Anonymous, published by Raymond Chen

    Don't PM me with your problems, I scan most of the forums daily. If you do PM me, I will not answer your question.

  10. #10
    I'm about to be a PowerPoster! mendhak's Avatar
    Join Date
    Feb 2002
    Location
    Ulaan Baator GooGoo: Frog
    Posts
    38,170
    Your page seems fine, but what if the amount of text you have to display is a lot? Try playing with that and see what happens.

    Btw how do i jump to a certain div tag, in the script?
    Not sure what you mean, could it be

    <a name="placename">Title flaskdjflaskjf</a>


    Then to jump to it, a link as such: <a href="#placename">Click here</a>

  11. #11

    Thread Starter
    transcendental analytic kedaman's Avatar
    Join Date
    Mar 2000
    Location
    0x002F2EA8
    Posts
    7,221
    yeah I want it to jump to the div tag, but not directly by clicking the link but when decided so trough javascript, the link calling the javascript function. My page doesn't have stuff enough for it to jump yet but once i have more than for it to fit into browser you would want to jump there.
    Code:
    		if(document.getElementById(url)!=null){
    			//JUMP to it here
    			return false;
    		}
    Use
    writing software in C++ is like driving rivets into steel beam with a toothpick.
    writing haskell makes your life easier:
    reverse (p (6*9)) where p x|x==0=""|True=chr (48+z): p y where (y,z)=divMod x 13
    To throw away OOP for low level languages is myopia, to keep OOP is hyperopia. To throw away OOP for a high level language is insight.

  12. #12
    Kitten CornedBee's Avatar
    Join Date
    Aug 2001
    Location
    In a microchip!
    Posts
    11,594
    On modern browsers this works:
    Code:
    location.href += "#" + thediv.id;
    // or thediv.getAttribute("id");
    All the buzzt
    CornedBee

    "Writing specifications is like writing a novel. Writing code is like writing poetry."
    - Anonymous, published by Raymond Chen

    Don't PM me with your problems, I scan most of the forums daily. If you do PM me, I will not answer your question.

  13. #13
    I'm about to be a PowerPoster! mendhak's Avatar
    Join Date
    Feb 2002
    Location
    Ulaan Baator GooGoo: Frog
    Posts
    38,170
    Originally posted by CornedBee
    On modern browsers this works:
    Code:
    location.href += "#" + thediv.id;
    // or thediv.getAttribute("id");
    Yes, as opposed to browsers from the 1600s.

  14. #14
    Kitten CornedBee's Avatar
    Join Date
    Aug 2001
    Location
    In a microchip!
    Posts
    11,594
    Hey, I'm not sure if even IE5.5 works with # and element ids.
    All the buzzt
    CornedBee

    "Writing specifications is like writing a novel. Writing code is like writing poetry."
    - Anonymous, published by Raymond Chen

    Don't PM me with your problems, I scan most of the forums daily. If you do PM me, I will not answer your question.

  15. #15

    Thread Starter
    transcendental analytic kedaman's Avatar
    Join Date
    Mar 2000
    Location
    0x002F2EA8
    Posts
    7,221
    Thanks again, I had to do a little modification though, or it would add up the #'s:
    location.href = "#" + url;
    Use
    writing software in C++ is like driving rivets into steel beam with a toothpick.
    writing haskell makes your life easier:
    reverse (p (6*9)) where p x|x==0=""|True=chr (48+z): p y where (y,z)=divMod x 13
    To throw away OOP for low level languages is myopia, to keep OOP is hyperopia. To throw away OOP for a high level language is insight.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width