Solved

Adding Link to Php code.

Posted on 2007-04-08
12
200 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
Master Your Team's Linux and Cloud Stack!

The average business loses $13.5M per year to ineffective training (per 1,000 employees). Keep ahead of the competition and combine in-person quality with online cost and flexibility by training with Linux Academy.

 
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
 
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

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
PHP Parse error: syntax error, unexpected '[' 1 25
maybe no no httpd.conf 6 47
PHP Installer 5 24
How can I make this form submit to itself? 10 27
This article will explain how to display the first page of your Microsoft Word documents (e.g. .doc, .docx, etc...) as images in a web page programatically. I have scoured the web on a way to do this unsuccessfully. The goal is to produce something …
Foreword (July, 2015) Since I first wrote this article, years ago, a great many more people have begun using the internet.  They are coming online from every part of the globe, learning, reading, shopping and spending money at an ever-increasing ra…
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.

810 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