Solved

Adding Link to Php code.

Posted on 2007-04-08
12
198 Views
Last Modified: 2010-04-21
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!
0
Comment
Question by:Rowby Goren
  • 6
  • 5
12 Comments
 
LVL 20

Expert Comment

by:steelseth12
ID: 18873382
<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
 
LVL 29

Expert Comment

by:rdivilbiss
ID: 18873669
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
 
LVL 9

Author Comment

by:Rowby Goren
ID: 18873723
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
 
LVL 29

Expert Comment

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



0
 
LVL 29

Expert Comment

by:rdivilbiss
ID: 18873800
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
 
LVL 9

Author Comment

by:Rowby Goren
ID: 18873803
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
6 Surprising Benefits of Threat Intelligence

All sorts of threat intelligence is available on the web. Intelligence you can learn from, and use to anticipate and prepare for future attacks.

 
LVL 9

Author Comment

by:Rowby Goren
ID: 18873807
Hold on --- I'll try your second solution now to see if it keeps the hand instead of the arrow.

Stay tuned...

0
 
LVL 29

Expert Comment

by:rdivilbiss
ID: 18873811
#ja-sh {
    cursor:hand;
}
0
 
LVL 9

Author Comment

by:Rowby Goren
ID: 18873938
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
 
LVL 29

Accepted Solution

by:
rdivilbiss earned 500 total points
ID: 18874024
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
 
LVL 9

Author Comment

by:Rowby Goren
ID: 18874218
I'll find that DIV.     May not get back to it until Tues...

Stay tuned!
0
 
LVL 9

Author Closing Comment

by:Rowby Goren
ID: 31407192
THanks for your help and sorry for the delay in awarding the points!
0

Featured Post

Highfive + Dolby Voice = No More Audio Complaints!

Poor audio quality is one of the top reasons people don’t use video conferencing. Get the crispest, clearest audio powered by Dolby Voice in every meeting. Highfive and Dolby Voice deliver the best video conferencing and audio experience for every meeting and every room.

Join & Write a Comment

Consider the following scenario: You are working on a website and make something great - something that lets the server work with information submitted by your users. This could be anything, from a simple guestbook to a e-Money solution. But what…
Things That Drive Us Nuts Have you noticed the use of the reCaptcha feature at EE and other web sites?  It wants you to read and retype something that looks like this.Insanity!  It's not EE's fault - that's just the way reCaptcha works.  But it is …
The viewer will learn how to count occurrences of each item in an array.
This tutorial will teach you the core code needed to finalize the addition of a watermark to your image. The viewer will use a small PHP class to learn and create a watermark.

758 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

22 Experts available now in Live!

Get 1:1 Help Now