|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
Stay one step ahead of the competition. Evaluate and give feedback
on some of the hottest web development tools on the market today.
Make your opinion heard! Click
Here
|
|
#1
|
|||
|
|||
|
Code problem
So,this is my first problem in php.
I have script for replace bb code in to html,for HTML links this is like this: Code:
$novica = ereg_replace( "([-_./a-zA-Z0-9!&%#?,'=:~]+)", "(<a href="\1">\1</a>", $novica); Ewerything works fine, but how can i open this link in new window? |
|
#2
|
|||
|
|||
|
RE: Code problem
You can use Javascript for it.
Or you can pass a var by get and sent it to a script here you have Header ( location : http://domain.whatever/pagetoopen.php); be well. |
|
#3
|
|||
|
|||
|
RE: Code problem
If you want a link to open in a new window when someone clicks on it, just add the target parameter, i.e.:
<a href="http://codewalkers.com/" target="_blank">Click here!</a> |
|
#4
|
|||
|
|||
|
RE: Code problem
I understand this with target="_blanc". Butt, how can I define this in my code or maybe better wher.
Ereg_replace function automatic replace bb code with html and i so I have something like www.domain.com. All I wont is this link like www.domain.com opens in new window. Here on Codewalker index page you have news.Last news is for Enterprise php. When I click on link in this news Enterprise php pege opens in new window, butt old Codewalkers windew stey. OK, I hope you get the point of my problem. BTW, sorry for my bad english. |
|
#5
|
|||
|
|||
|
RE: Code problem
trie: <a href="http://www.domain.com/index.php" target="_blank">Click here</a>
|
|
#6
|
|||
|
|||
|
RE: Code problem
I thing you dont understand my problem. Look, this is my php code:
$news = ereg_replace( "([-_./a-zA-Z0-9!&%#?,'=:~]+)", "(<a href="\1">\1</a>", $news); This code automatic replace bb code with html code for links, so when i wrote bb code for link i becomme on my screen something like www.domain.com. Ewerything fine. Problem here is, i want this link open in new window. What is missing in php code. |
|
#7
|
|||
|
|||
|
RE: Code problem
try:
$news = ereg_replace( "([-_./a-zA-Z0-9!&%#?,'=:~]+)", "(<a href="\1" target="_blank">\1</a>", $news); |
|
#8
|
|||
|
|||
|
RE: Code problem
dont work
Parse error: parse error, unexpected '(' |
|
#9
|
|||
|
|||
|
RE: Code problem
Ahh, the problem is that this forum is parsing the url tags you have in your ereg statement..check this text file for how it should be:
http://codewalkers.com/ereg.txt |
|
#10
|
|||
|
|||
|
RE: Code problem
|
|
#11
|
|||
|
|||
|
RE: Code problem
Matt, its nothing wrong with this code. It works fine.
Butt not open a link in new window. |
|
#12
|
|||
|
|||
|
RE: Code problem
The ereg_replace statement in that text file produces a link that opens in a new window for me. It creates a link that has a target="_blank" property, which will open a new window...
|
|
#13
|
|||
|
|||
|
RE: Code problem
Matt, this is OK.
Ereg replace produses a new window link. Lets say diferent. I have news page with link in it. Wenn i click on link new window opens, butt old page with news stays alive. :cool |
|
#14
|
|||
|
|||
|
RE: Code problem
i did it with very unefficient but working method
search for [ url ] search for [ /url ] (edit) you really need to add No BBCode parsing feature. Remove the extra spaces.(/edit) take the string between two use <a href="<?=$str?>"><?=$str?></a> messy but works fine. I do need to learn RegExp sometime soon |
|
#15
|
|||
|
|||
|
RE: Code problem
Now, it works
CODE Code:
$novica = ereg_replace("([-_./a-zA-Z0-9!&%#?,'=:~]+)","(<a href="\1" target="_blank">\1</a>", $novica);
Thanx to all. |
![]() |
| Viewing: Codewalkers Forums > PHP Related > PHP Coding > Code problem |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|