TP-Docs
HTML5 Icon HTML5 Icon HTML5 Icon
TP on Social Media

Recent

Welcome to TinyPortal. Please login or sign up.

March 29, 2024, 05:13:49 AM

Login with username, password and session length
Members
Stats
  • Total Posts: 195,105
  • Total Topics: 21,213
  • Online today: 310
  • Online ever: 3,540 (September 03, 2022, 01:38:54 AM)
Users Online
  • Users: 1
  • Guests: 284
  • Total: 285
  • lurkalot

Open url in new tab HELP NEEDED

Started by diegolyanky, October 21, 2013, 06:08:35 PM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

diegolyanky

Yes, sorry for double post...

I used your code, but i'm not sure if is ok or not (maybe bad syntax)


<input name="msg" type="text" /><button>BUSCAR</button>

<script>
    document.querySelector('button').addEventListener('click', function() {
        var msg = document.querySelector('input[name=msg]').value.replace(/ /g, '+');
window.open("http://www.mysite.com/index.php?action=profile;u=' + msg, '_blank');
</script>



Is ok ? ... Don't works for me ... :(

IchBin

You cannot have a mixture of double and single quotes like that. If you take the line I posted above here:
http://www.tinyportal.net/index.php?topic=35241.msg281392#msg281392

Replace the line in your code with that line and it should work.

diegolyanky

Quote from: IchBin™ on October 21, 2013, 09:44:12 PM
You forgot a couple of single quotes in your window.open.
window.open('http://www.mysite.com/index.php?action=profile;u=' + msg, '_blank');

That code opens a new tab for me in Chrome and Firefox.

Is not working for me...


so was the code, with the recommendation that you have given me.

Is my code as well?

<input name="msg" type="text" /><button>BUSCAR</button>

<script>
    document.querySelector('button').addEventListener('click', function() {
        var msg = document.querySelector('input[name=msg]').value.replace(/ /g, '+');
window.open('http://www.ecuforo.com/index.php?action=profile;u=' + msg, '_blank');
</script>


What we do not know is if I put the code you gave me in the right line.

IchBin

You put the line in the right location. Only it seems you have removed some code. You are missing the closing }); for the addEventListener function. Try this code.

<input name="msg" type="text" /><button>BUSCAR</button>

<script>
    document.querySelector('button').addEventListener('click', function() {
        var msg = document.querySelector('input[name=msg]').value.replace(/ /g, '+');
window.open('http://www.ecuforo.com/index.php?action=profile;u=' + msg, '_blank');
    });
</script>

diegolyanky

Yeah !!...
It works !!

Thanks IchBin... ( gift for you, check your email ;) )