[Javascript] Code optimization

tedd tedd at sperling.com
Mon Aug 7 10:25:04 CDT 2006


At 10:05 AM -0400 8/7/06, Terry Riegel wrote:
>Hello,
>
>I need a little help optimizing the following code.
>
><div class="nor" id="004LukeShannon.jpg">
>  <A 
>href="javascript:windowHandle=window.open('http://clearimageonline.com/pages/htmlos/94150.128.040923622659991927', 
>'CIclearimage004LukeShannonjpg', 
>'width=550,height=550,status=yes,scrollbars=yes,resizable=yes,left=150');windowHandle.focus();" >
>   <img src="/clearimage/images/pict-small.gif" border="0" width="12" 
>height="12" align="left">
>  </A>
>  <a href="javascript:changedest('004LukeShannon.jpg','FILE')" 
>ondblclick="changedest2('004LukeShannon.jpg','FILE')">
>   004LukeShannon.jpg
>  </a>
></div>
>
>
>What I would like to do is replace some of the references in the 
>second <a> tag with a relative reference to the containing div. I 
>would also like to replace all of the links on the page with similar 
>code, I think there is a way to do this in a script that will apply 
>to all links globally for that page. I would just need to know the 
>second argument in my code either "FILE" or "DIR"
>
>Any help would be appreciated.
>
>Terry

Terry:

I'm not sure if I am understanding you correctly (probably not), but 
if it were me and I wanted to simplify the above code, I would use 
php. For example, instead of using "004LukeShannon.jpg" throughout 
your code, such as:

<div class="nor" id="004LukeShannon.jpg">

I would use:

<?php $image = "004LukeShannon.jpg"?>

<div class="nor" id="<?php echo $image; ?>">

That way you declare the image only once at the beginning of your 
code and use <?php echo $image; ?> for everywhere you want the 
image-name to appear.

hth's

tedd

-- 
-------
http://sperling.com  http://ancientstones.com  http://earthstones.com



More information about the Javascript mailing list