Adding Link to Php code.

Hi Experts,

I need to include a link to another url to this bit of php code:

<div id="ja-sh" class="clearfix" style="background:url(<?php echo "$ja_template_path/images/$ja_color/$ja_headerimg"; ?>) no-repeat top right; ">

How would I do it.  Assume the link is to "http://www.foobar.com" and it would be in a new window.

Thanks!
LVL 9
Rowby GorenAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

steelseth12Commented:
<a href="http://www.foobar.com" target="_blank">http://www.foobar.com</a> is this what you want ???

Im not sure i understood the question .
0
rdivilbissCommented:
For a division, you will need to add the onclick event handler.

<div id="ja-sh" class="clearfix" style="background:url(<?php echo "$ja_template_path/images/$ja_color/$ja_headerimg"; ?>) no-repeat top right; " onclick="openPopup('http://www.foobar.com')">

And you will need an event handler in JavaScript which you place within the HEAD tags of your page.

<script language="javascript" type="text/javascript">
<!--
var childPopup = null;

function openPopup(pURL) {
  // If the child popup is open, close it.
  if (childPopup != null) {
    if (childPopup.closed == false)
      childPopup.close()
  }
  // open the child popup.
  childPopup = window.open(pURL,'child');
  // return the window handle.
  return childPopup;
}
</script>

Regards,
Rod
0
Rowby GorenAuthor Commented:
Hi Rod,

After speaking with my client, he says he does not want it to be a popup.  SO can you revise your script so it opens in the same window.

Thanks

Rowby
0
Introducing Cloud Class® training courses

Tech changes fast. You can learn faster. That’s why we’re bringing professional training courses to Experts Exchange. With a subscription, you can access all the Cloud Class® courses to expand your education, prep for certifications, and get top-notch instructions.

rdivilbissCommented:
<script language="javascript" type="text/javascript">
function openPopup(pURL) {  // is now a stupid name for this function
     document.location = pURL;
}
</script>



0
rdivilbissCommented:
Of course, if you are going to open it in the same window, you probably can simply do this....


<a href="http://www.foobar.com"><div id="ja-sh" class="clearfix" style="background:url(<?php echo "$ja_template_path/images/$ja_color/$ja_headerimg"; ?>) no-repeat top right; "></a>

Rod
0
Rowby GorenAuthor Commented:
Works perfectly Sage.

Is there any way to force the arrow to be a hand when it hovers over the link.  Or is this something I need to ask in Experts Exchane CSS section.

Rowby
0
Rowby GorenAuthor Commented:
Hold on --- I'll try your second solution now to see if it keeps the hand instead of the arrow.

Stay tuned...

0
rdivilbissCommented:
#ja-sh {
    cursor:hand;
}
0
Rowby GorenAuthor Commented:
Hmmm Sage,
For some reason your solution has "stopped working".  The hand is fine.  But in both IE and Firefox the link does't work.

I think it could have to do with the page failing validation.  If you can go to this link and then to the bottom of the page you will see a W3C link where you can check the 2 valdation problems.  If this is beyond the scope of this question/ EE Forum, then let me know and I will take a short visit to the IE Css section.

http://www.coveryourcar.com/new/

THe link that we have been working on is the Start Here button.
No hurry.  This page is not live.

Rowby
0
rdivilbissCommented:
Oh looks like you're missing a ending <.DIV> tag someplace.

I like the onclick with CSS the best.  Wrapping a DIV with an anchor could have some issues.
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Rowby GorenAuthor Commented:
I'll find that DIV.     May not get back to it until Tues...

Stay tuned!
0
Rowby GorenAuthor Commented:
THanks for your help and sorry for the delay in awarding the points!
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
PHP

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.