OnClick with popup

#1
[eluser]frietkot[/eluser]
Hi,

I want to make a div with onClick and the popup function from the url helper.
This is what I've got:
Code:
onClick="window. location. href='<?=anchor_popup('news/local/123', 'Click Me!')?>';"

but that's not working and it only prints out html data like this:
Code:
Click Me!';" onMouseOver="style.backgroundColor='#EEEEEE';" onMouseOut="style.backgroundColor='#FFFFFF'" style="cursor: pointer;">

What am I doing wrong and what is the solution?

#2
[eluser]jcopling[/eluser]
From the documentation:
Quote:Here are some examples:

echo anchor('news/local/123', 'My News');
Would produce: <a href="http://example.com/index.php/news/local/123" title="My News">My News</a>

echo anchor('news/local/123', 'My News', array('title' => 'The best news!'));
Would produce: <a href="http://example.com/index.php/news/local/123" title="The best news!">My News</a>

The anchor and anchor_popup functions from the URL helper do not return URL strings, they return HTML anchor entities. So by using the anchor function to set the window location you would be producing something like:

http://<a href="http://www.mydomain/com">Click Me!</a>

Instead, you would use the base_url function to produce the URL string that you want to direct to:
Code:
onClick="window. location. href='&lt;?= base_url();?&gt;news/local/123;"

#3
[eluser]frietkot[/eluser]
Thanks, but I know that.
That's not the solution of using the anchor popup function.

#4
[eluser]xwero[/eluser]
the anchor_popup function adds an a tag with an onclick attribute so you are adding a tag to your own onclick event.

My question is why would you want a popup and a reload of the page at the same time? Either you just reload the page with a simple a tag or you do a popup where you can use the popup_anchor function.


Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  


  Theme © 2014 iAndrew  
Powered By MyBB, © 2002-2021 MyBB Group.