Solved

Adding Link to Php code.

Posted on 2007-04-08
12
199 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
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 
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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Password hashing is better than message digests or encryption, and you should be using it instead of message digests or encryption.  Find out why and how in this article, which supplements the original article on PHP Client Registration, Login, Logo…
This article discusses four methods for overlaying images in a container on a web page
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.

919 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

21 Experts available now in Live!

Get 1:1 Help Now