Welcome Guest, Not a member yet? Register   Sign In
[SOLVED]     Is it possible to display a link and use onclick() to call anchor_popup()?
#1

[eluser]John_Betong_002[/eluser]
I have dug myself into a deep hole and now trying to climb out by trying to reduce the size of the displayed page Sad

Problem
I have a page that displays a couple of thousand anchor_popup() links each duplicating the following code:

Code:
<?php
  echo anchor_popup('url_001','url_title_001',$atts);
?>

// expands to
<a
  href='java-script:void(0);'
  onclick="window.open('http://mysite.com/popup/url_001.html', '_blank',
  'width=800,height=600,scrollbars=yes,status=no,resizable=yes,screenx=200,screeny=100');"
>
  url_title
</a>

... repeated a couple of thousand times :(
 

[/b]Question[/b]
Is it possible to replace the above code with:
Code:
<a href='#' onclick='fn_call_popup('url_001')'>
  url_title_001
</a>
// should not expand and thus considerably reduce the page size.
 

I have tried writing the javascript function fn_call_popup('url_001.html'); and ran into problems. I would like confirmation that it is possible before further attempts at trying to get it to do what I want it to do.
 
 
 
#2

[eluser]jmadsen[/eluser]
my bad - I didn't realize anchor_popup() was a helper function

actually, I'm really unclear what you are having trouble with. you want to call a popup window from a javascript function in an anchor? sure, you can do that.

put an href="#" in the tag, and return false so the page doesn't jump around.
#3

[eluser]John_Betong_002[/eluser]
'done it and quite chuffed:
 

comparison of output results
Code:
#=================================================
# Old code repeated a couple of thousand times
# filesize() = 582,317 bytes
#=================================================
<a
  href='java-script:void(0);'
  onclick="window.open('http://mysite.com/popup/url_001.html', '_blank',
  'width=800,height=600,scrollbars=yes,status=no,resizable=yes,screenx=200,screeny=100');"
>


#=================================================
# New code repeated same number of times
# filesize() = 164,680 bytes
#=================================================
<a
    href='#' on-click d(table->row->id)"
>
    table->row->name
&;gt;/a>



#=================================================
# bytes saved = 417,637 bytes
# reduction   =  28.28%
#=================================================
 
size matters Smile
 
 
 
edit: deliberate misspelling of java-script and on-click and still some of the java stuff has been removed.




Theme © iAndrew 2016 - Forum software by © MyBB