PDA

Click to See Complete Forum and Search --> : [RESOLVED] # page load


Jazza
Feb 2nd, 2007, 10:02 PM
echo ' <a href="#" onclick="window.open(\http://wahteversite.com/wahtever.php,\start\,\left=200,top=150,height=510,width=595,status\); return false;"><img src="/image.jpg" border="0"></a>
</ul>';

Any Ideas why i get
http://wahteversite.com/wahtever.php#

instead of http://wahteversite.com/wahtever.php

Thanks in advance
Excluding the [url] bbc tags

kows
Feb 3rd, 2007, 12:08 AM
because you put a hash sign in the href attribute. why else?

penagate
Feb 3rd, 2007, 01:04 AM
Eww. Just eww.

echo()ing HTML code; using an event handler attribute; using window.open... I can't see anything good in that code, to be honest, and it's only one line. I shudder to think what the rest of it looks like.

Jazza
Feb 3rd, 2007, 01:43 PM
because you put a hash sign in the href attribute. why else?
HUH? Ok now

Eww. Just eww.
LOL atleast your honest Penagate

Is this better?
echo "<a href=\"#\" onclick=\"javascript: window.open('http:mysite.com','start','left=200,top=150,height=510,width=595,status'); return false;\"><img src=\"/virus.jpg\" border=\"0\"></a></ul>";

penagate
Feb 3rd, 2007, 02:01 PM
If anything, it looks worse.

Here is a post by visualAd that explains the basics of code formatting in PHP (http://vbforums.com/showpost.php?p=2440249&postcount=7). Outputting HTML using echo() is inefficient, less readable, and error-prone, as you need to escape various characters.

Don't open pop-up windows: it's grossly 90s, and will be blocked by just about all modern browsers, leading to a messy, interrupted user experience. In general, don't tamper with browsing models in any way; just use plain links to navigate between pages. If you want to show a pop-up on the page, use Javascript; but be sure to provide a vanilla HTML solution for those without Javascript enabled/supported.


Edit: Here's a post by yours truly with some more points about why outputting using echo() is bad (http://vbforums.com/showpost.php?p=2529197&postcount=6).

Jazza
Feb 3rd, 2007, 02:32 PM
Thanks for the reads. I see what your saying.

kows
Feb 3rd, 2007, 03:59 PM
you asked why you were getting your URL with a hash at the end of it. "#" is the hash character. you made the href attribute a hash, thus why you're getting the hash character at the end of your URL.

Jazza
Feb 3rd, 2007, 04:18 PM
you asked why you were getting your URL with a hash at the end of it. "#" is the hash character. you made the href attribute a hash, thus why you're getting the hash character at the end of your URL.
Nevermind :sick:

dclamp
Feb 3rd, 2007, 08:33 PM
Nevermind :sick:

you are acting like you have absolutly no idea what he is talking about!!

listen.

When you put a '#' in the 'href', then it reloads your page with the '#' at the end.


<a href='#'>Link</a>


if you dont want that to happen, then put the javascript in place of the #

Jazza
Feb 4th, 2007, 12:57 AM
Like i did in post #4 :sick:

dclamp
Feb 4th, 2007, 03:58 PM
Like i did in post #4 :sick:
no..

Jazza
Feb 4th, 2007, 08:38 PM
I'm lost then. Its working just fine like this.
echo "<a href=\"#\" onclick=\"javascript: window.open('http:mysite.com','start','left=200,top=150,height=510,width=595,status'); return false;\"><img src=\"/virus.jpg\" border=\"0\"></a></ul>";
Keep in mind I'm new to all of this as seen above
http://www.vbforums.com/showthread.php?t=449182
See i also created the newb thread.

dclamp
Feb 4th, 2007, 09:05 PM
I'm lost then. Its working just fine like this.
echo "<a href=\"#\" onclick=\"javascript: window.open('http:mysite.com','start','left=200,top=150,height=510,width=595,status'); return false;\"><img src=\"/virus.jpg\" border=\"0\"></a></ul>";
Keep in mind I'm new to all of this as seen above
http://www.vbforums.com/showthread.php?t=449182
See i also created the newb thread.
i can see that you new, you cant even spell n00b!

Jazza
Feb 4th, 2007, 09:09 PM
See my entire point!!!
n00b!

penagate
Feb 4th, 2007, 09:56 PM
There's no need for that, either of you.


Jazza: Get rid of all the Javascript. Triggering script from links isn't a great idea at the best of times. Buttons (<button>) are more logical.

Assign event handlers from your script, which should be in an external .js file. Don't put them inline in the HTML, it's messy.

Also, href="#" is meaningless. href should always point to a page. If you must trigger script from a link, override the link action from your event handler by using e.preventDefault() (and whatever the IE equivalent is, I forget).


dclamp: Stop stirring.

Jazza
Feb 4th, 2007, 10:07 PM
Thanks for the info Penagate.
I learn something new everytime I come to this board.

dclamp
Feb 4th, 2007, 11:52 PM
Thanks for the info Penagate.
I learn something new everytime I come to this board.

dont forget! give rep to all who helped, and even thoes who didnt that much ;)

EDIT:

also, mark thread as "Resolved"

Jazza
Feb 5th, 2007, 12:37 AM
Sure thing boss.
I'll make the thread read "resolved"