#1
  1. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jun 2000
    Posts
    14
    Rep Power
    0
    Okay, I know how to replace a URL with its hyperlink equivalent. However, what if someone enters code such as the following.

    <IMG SRC="http://www.netigen.com/img.gif">

    This would become..

    <IMG SRC="<A HREF="http://www.netigen.com/img.gif">http://www.netigen.com/img.gif</A>">

    How can I work around this problem so that the hyperlink is only replaced if its not part of another tag (preceded by '=', '="', or "='" and closed with a ", ' or space)
  2. #2
  3. .Net Developer
    Devshed Novice (500 - 999 posts)

    Join Date
    Feb 2000
    Location
    London
    Posts
    987
    Rep Power
    15

    <IMG SRC="<A HREF="http://www.netigen.com/img.gif">http://www.netigen.com/img.gif</A>">



    Hyperlink inside the img tag???????

    It is not possible Raze2k..

    But you can do...

    -----------------------
    <A HREF="http://www.netigen.com/img.gif">
    <IMG SRC="http://www.netigen.com/img.gif"></A>

    ---
    or probably you can try for a hotspot..

    eg:

    <map name="FPMap0">
    <area href="http://www.netigen.com/img.gif" shape="rect" coords="2, 6, 10, 10"></map><img border="0" src="http://www.netigen.com/img.gif" usemap="#FPMap0" width="12" height="12">




    ------------------
    SR -
    webshiju.com

    "The fear of the LORD is the beginning of knowledge..."
  4. #3
  5. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jun 2000
    Posts
    59
    Rep Power
    15
    I think he meant that if someone that he has a form, and people can type in html, but he is replacing the http://'s with a hyperlink, but if somone types in an img tag, it will also replace the http with a hyperlink, so he wants to know how to find if it is part of an image tag, or if it should be turned into a hyperlink.

    I would probably have to see some of your code, are you doing it with ereg, ereg_replace, substr_replace?

    Chris
  6. #4
  7. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jun 2000
    Posts
    14
    Rep Power
    0
    right now, the code is:

    $postform = eregi_replace( "([[:alnum:]]+)://([^[:space:]]*)([[:alnum:]#?/&=]]*)", "<A HREF="1://23">1://23</A>", $preform);
  8. #5
  9. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jun 2000
    Posts
    59
    Rep Power
    15
    Ok, you could try somethng like this:

    if(!stristr($preform, "<IMG SRC=")
    {
    $postform = eregi_replace( "([[:alnum:]]+)://([^[:space:]]*)([[:alnum:]#?/&=]]*)", "<A HREF="1://23">1://23</A>", $preform);
    }

    Chris

Similar Threads

  1. offset limit hyperlink
    By tragnark in forum PHP Development
    Replies: 2
    Last Post: February 10th, 2004, 04:19 PM
  2. get next id before insertion
    By emory in forum MySQL Help
    Replies: 20
    Last Post: February 5th, 2004, 12:15 AM
  3. insertion limit of speed and frequency
    By wujie in forum MySQL Help
    Replies: 3
    Last Post: August 30th, 2002, 01:21 PM
  4. How to access hyperlink hover attributes using Javascript ?
    By sk8ertim in forum JavaScript Development
    Replies: 6
    Last Post: May 31st, 2001, 10:50 AM
  5. Smart Hyperlink Creation
    By Raze2k in forum PHP Development
    Replies: 0
    Last Post: September 6th, 2000, 12:11 AM

IMN logo majestic logo threadwatch logo seochat tools logo