Jump to content

how to open page in new tab


Techrits

Recommended Posts

Hello friends this is my first thread (and post)

I just created a site and my query is that suggest me code for opening a link in new tab after the user presses button which in result navigates to another page. for better understanding please visit my site www.mysearchengine.tk there when user types a query and hit "GO" button the result must be shown in another tab (or window). Hope you got my query.

Link to comment
Share on other sites

No this does not work because in my code I did not used a href at all...

for better understanding I am putting that piece of code here

 

               

case "wgoogle":
		if($_GET["pressed"]==1)
		header("Location: http://www.google.co.in/search?q={$query}");
	break;

 

as you can see I did not used html to open a link.

Link to comment
Share on other sites

No this does not work because in my code I did not used a href at all...

for better understanding I am putting that piece of code here

 

               

case "wgoogle":
		if($_GET["pressed"]==1)
		header("Location: http://www.google.co.in/search?q={$query}");
	break;

 

as you can see I did not used html to open a link.

you did not specify what you were trying to do. hopefully the above post will help.

Link to comment
Share on other sites

What you can do, is put a submit button inside an anchor tag, so assuming you're using a button, you can make it open in a new tab like this:

 

<a href="http://link.link" target="_blank"><input type="submit" /></a>

 

In terms of having it inside a select, you'll have to do something like this:

 

case "wgoogle":
		if($_GET["pressed"]==1)
		echo '<script type="text/javascript">window.open("http://gumclan.org", "_blank");</script>';
	break;

 

But for me, that's opening in a new window and not a new tab.

 

I hope I helped in some way :)

Link to comment
Share on other sites

@pseud

 

That's invalid mark-up; you can't have a button within an a tag.

 

@Techrits

 

I don't understand why you want to open results in another tab/window? That's just going to annoy the user when they can't click back. If I want pages to open in a new tab I do it manually

Link to comment
Share on other sites

@pseud

 

That's invalid mark-up; you can't have a button within an a tag.

 

@Techrits

 

I don't understand why you want to open results in another tab/window? That's just going to annoy the user when they can't click back. If I want pages to open in a new tab I do it manually

 

It works though :o

Link to comment
Share on other sites

It's not like any browsers deny invalid markup, if it works then it works, surely?

 

I guess it's an opinion, I gave a working solution but it depends on the user whether or not they're happy to use invalid markup in their document - it's unfair to call my solution invalid based on your opinion of it though.

Link to comment
Share on other sites

It's not like any browsers deny invalid markup, if it works then it works, surely?

 

Of course they do. IE barely accepts valid markup.

 

And even if it did work, it is an unnecessary, hacky solution. Just because it might "work" doesn't mean you should do it. That is a very bad philosophy to have as a programmer.

Link to comment
Share on other sites

I didn't say your solution was invalid, I said the mark-up it produced was invalid. There's a certain amount of tolerance towards breaking standards 'to get the job done', but the reason the OP is having difficulty doing what he wants to do is because you're not meant to do it. That's why throwing together hacky code to get it working is frowned on. There's a reason for standards..

Link to comment
Share on other sites

Also think about the seo of the page, it all needs to be validated.

 

if a spider hit a incorrect formatted html xhtml page then the spider spits a error then your page is put lower in the spider it self(that the theory any way.)

 

 

Just looked at your website, and the way your scrapping other spiders well slow why?

Link to comment
Share on other sites

Oh right, I was gonna say - my site is SMF and only has a few custom pages.

 

I apologise for my bad information by the way. I'm new to this scene, ill not say stuff unless I'm totally sure now. I don't wanna be that forum guy who pretends to know everything haha x

Link to comment
Share on other sites

i was thank you scootstah

 

Techrits not your web site.

 

scootstah grate programmer and you seem to no the theory so well,i would love to how to do programming so well as you, thanks for helping us all.

 

i guess it takes practice and loads of it to be any good at php mysql

 

sorry i am a bad speller and writer

 

Link to comment
Share on other sites

  • 2 weeks later...

@pseud

 

That's invalid mark-up; you can't have a button within an a tag.

 

@Techrits

 

I don't understand why you want to open results in another tab/window? That's just going to annoy the user when they can't click back. If I want pages to open in a new tab I do it manually

 

Thank to all for your reply.

Sorry for late reply actually my problem was solved and hence I never looked at this thread.

@Adam

Just visit mysearchengine.tk once and then you will understand why I'm doing this coz there you can't open in new tab manually.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.