Jump to content

Recommended Posts

hello,

I need some help on a javascript code that allows a link to open in a new window....but it doesnt work when i use it with php.

 

here is my code:

echo  "<div align='left' class='FontColorsData'><span class='Public_Private_EmailFont'>Public Email:</span><a href='javascript:void(0)'onclick='window.open('Email_Request/form.html','linkname','height=400, width=450,scrollbars=no')'> Request an email NOW!</a></div>";

 

what am i missing?

PHP parses its own code and sends the results to the client.  javascript is not parsed by php.  It is sent to the browser to be rendered.  Your php is syntactically correct, so that stuff will be echoed.  So...you're going to have to be more specific than "It doesn't work."

well.....when i click the link.....i dont get a pop up window of the form

 

but i just figured out the problem....not sure how to fix it though

 

this is what i am using


//this one doesnt work in php because im forced to use single qouts '.....if i use double " i get error

<div align='left' class='FontColorsData'><span class='Public_Private_EmailFont'>Public Email:</span><a href='javascript:void(0)'onclick='window.open('/Email_Request/form.html','linkname','height=400, width=450,scrollbars=no')'> Request an email NOW!</a></div>



//this one works!! BUT....its because this one has double qouts ".....and i tested it in HTML...if i paste this in php i get error


<div align='left' class='FontColorsData'><span class='Public_Private_EmailFont'>Public Email:</span><A HREF="javascript:void(0)"onclick="window.open('/Email_Request/form.html','linkname','height=400, width=450,scrollbars=no')"> Request an email NOW!</a></div>

 

 

so basically it conflicts with the double quotes of the beginning echo "<...javascript....>";

 

 

 

 

you can escape double quotes with a backslash

 

<?php
echo "<div align='left' class='FontColorsData'><span class='Public_Private_EmailFont'>Public Email:</span><A HREF=\"javascript:void(0)\"onclick=\"window.open('http://www.clone003.site40.net/Email_Request/form.html','linkname','height=400, width=450,scrollbars=no')\"> Request an email NOW!</a></div>";
?>

LOL AWESOME JOB!

 

i never knew that was possible......

 

THANKS FOR YOUR HELP GUYS!!!

 

 

it required just two more backslashes and it works great.....if anyone needs it in the future its below.


echo  "<div align='left' class='FontColorsData'><span class='Public_Private_EmailFont'>Public Email:</span><A HREF=\"javascript:void(0)\" onclick=\"window.open('/Email_Request/form.html','linkname','height=400, width=450,scrollbars=no')\"> Request an email NOW!</a></div>";

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.