Hyperlink with javascript

Talk about link fields or link implementations

Moderator: alexandrleonenko

albert
Newbie
Newbie
Posts: 3
Joined: Aug 3rd, '09, 15:24

Hyperlink with javascript

Postby albert » Aug 19th, '09, 15:36

Hi,
How is the procedure to open a Hyperlink with javascript function?

My code:
"room_avail_$lang"=>array("header"=>"$ROOMSVIEW", "width"=>"X%|Xpx", "wrap"=>"wrap|nowrap", "text_length"=>"-1", "tooltip"=>"false", "tooltip_type"=>"floating|simple", "case"=>"normal|upper|lower|camel", "summarize"=>"false", "sort_type"=>"string|numeric", "sort_by"=>"", "visible"=>"true", "on_js_event"=>"", "field_room_id_0"=>"field_room_id_0", "field_key"=>"room_id", "field_data"=>"room_avail_$lang","align"=>"left", "target"=>"_new", "type"=>"link", "href"=>"propcal/index.php?hotel_id=$hotel_id&room_id={0}&lang=$lang")

My javascript function:
<script language="JavaScript">
function apri(url, w, h)
{
var int_windowLeft = (screen.width - w) / 2;
var int_windowTop = (screen.height - h) / 2;
var windowprops = "width=" + w + ",height=" + h+ ",top=" + int_windowTop + ",left=" + int_windowLeft;
popup = window.open(url,'Window',windowprops);
}
</script>

in bold the hyperlink.
I've try many solutions but probably i'm blind and don't see the solution... :oops:
Help pls.

administrator
Site Admin
Site Admin
Posts: 5997
Joined: Jan 7th, '09, 23:18
Contact:

Re: Hyperlink with javascript

Postby administrator » Aug 22nd, '09, 10:15

Solution:

Code: Select all

<script>
        function my_foo(){
            alert("Hello");
        }
</script>


In "link" field

Code: Select all

"target"=>"", "href"=>"javascript:my_foo();"),

administrator
Site Admin
Site Admin
Posts: 5997
Joined: Jan 7th, '09, 23:18
Contact:

Re: Hyperlink with javascript

Postby administrator » Aug 22nd, '09, 18:14


albert
Newbie
Newbie
Posts: 3
Joined: Aug 3rd, '09, 15:24

Re: Hyperlink with javascript

Postby albert » Sep 9th, '09, 15:29

Sorry, but don't works...
This is my link:

"room_avail_$lang"=>array("header"=>"$ROOMSVIEW", "type"=>"link" ,"width"=>"", "wrap"=>"wrap|nowrap", "text_length"=>"-1", "tooltip"=>"false", "tooltip_type"=>"floating|simple", "case"=>"normal|upper|lower|camel", "summarize"=>"false", "sort_type"=>"string|numeric", "sort_by"=>"", "visible"=>"true", "field_room_id_0"=>"field_room_id_0", "field_key"=>"room_id", "field_data"=>"room_avail_$lang","align"=>"left", "target"=>"", "on_js_event"=>"", "href"=>"javascript:popup(index.php?hotel_id=$hotel_id&room_id={0}&lang=$lang);"),

administrator
Site Admin
Site Admin
Posts: 5997
Joined: Jan 7th, '09, 23:18
Contact:

Re: Hyperlink with javascript

Postby administrator » Sep 12th, '09, 08:42

How exactly it doesn't work? Please explain in more details. did you check HTML source of the page you get? .... etc


Return to “Field type: "link"”