Tycoon Talk
Become a Big fish!
The number 1 forum for online business!
Post topics, ask questions, share your knowledge.
Tycoon Talk is part of Freelancer.com - find skilled workers online at a fraction of the cost.

JavaScript Forum


You are currently viewing our JavaScript Forum as a guest. Please register to participate.
Login



Reply
Extranenous http://www in front of strings
Old 08-28-2006, 10:56 PM Extranenous http://www in front of strings
Novice Talker

Posts: 11
Location: Melbourne, Australia
Trades: 0
Gudday all
A problem has being noted to my attention that has been on my wife's site for probably quite a while and is affecting users ability to e-mail us and review their cart.
The site is Petals & Patches - Applique, Bear, clothdoll, Stitchery, Quilt patterns
The problem concerns the E-mail Us and Review Cart buttons on the left hand side.
If you put your mouse over said buttons and look at the URL bar at the bottom of the screen you will note that you are given Petals & Patches - Applique, Bear, clothdoll, Stitchery, Quilt patterns in front of the necessary string, which is of course giving errors and eventually a 404 error.
The script fragment below has the error in it somewhere (I have removed the extraneous portions of the script)

[js]
var otherpages = new Array("accessories", "ordering", "contact us", "stockists", "e-mail us", "links", "review cart");

for (i=0; i < otherpages.length; i++) {
if (otherpages[i].indexOf("review") != -1) { //review cart button
image_name = otherpages[i];
pageurl = "http://www8.aitsafe.com/cf/review.cfm?userid=A736163";
document.write('<a href="../' + pageurl + '"><img src="../buttons/' + image_name + '.png" alt="Review your cart" height=24 width=125 border=0 vspace=2></a>');
}
else
if (otherpages[i].indexOf("-") != -1) { //e-mail us button
image_name = otherpages[i];
pageurl = "mailto:info&#64petalsandpatches.com";
document.write('<a href="../' + pageurl + '"><img src="../buttons/' + image_name + '.png" alt="E-mail us" height=24 width=125 border=0 vspace=2></a>');
}
else { //all other pages
image_name = otherpages[i];
pageurl = image_name;
document.write('<a href="../' + pageurl + '.htm"><img src="../buttons/' + image_name + '.png" alt="Go to the ' + pageurl + ' page" height=24 width=125 border=0 vspace=2></a>');
}
}
[/js]

I reckon the problem is in
[js]
document.write('<a href="../' + pageurl + '"><img src="../buttons/' + image_name + '.png" alt="E-mail us" height=24 width=125 border=0 vspace=2></a>');
[/js]
and
[js]
document.write('<a href="../' + pageurl + '"><img src="../buttons/' + image_name + '.png" alt="Review your cart" height=24 width=125 border=0 vspace=2></a>');
[/js]
Perhaps I'm using the " and ' incorrectly but after much searching and trying to rewrite the code I cannot see it.

Any help gratefully accepted.
Finches is offline
Reply With Quote
View Public Profile
 
 
Register now for full access!
Old 08-28-2006, 11:31 PM Re: Extranenous http://www in front of strings
vangogh's Avatar
Post Impressionist

Latest Blog Post:
Why Responsive Design?
Posts: 10,815
Name: Steven Bradley
Location: Boulder, Colorado
Trades: 0
The problem with both links is you have the ../ out in front of them. That's basically saying to start the link one folder up which in this case is the root folder. That's giving you the extra http:// etc out in front.

You don't need that ../ in front of either link since it doesn't make sense for the mailto: and because you're using an absolute url in the review cart button.

If the script is writing the urls for all the buttons you'll need to use some kind of conditional to test which button is being created and not add the ../ for those two links. In truth though using javascript to create the links isn't really a good idea. I'm assuming you want the pages of the site to be indexed in a search engine. Using javascript to create those links is a pretty big barrier to getting those pages found. Search engine spiders aren't going to be able to read the javascript as you have it and so won't know the pages beyond the home page exist.

There really isn't any need for that javascript. It would probably take less code to to use html than to use the javascript to create the buttons and links.
__________________
l Search Engine Friendly Web Design |
Please login or register to view this content. Registration is FREE

l Tips On Marketing, SEO, Design, and Development |
Please login or register to view this content. Registration is FREE

l
Please login or register to view this content. Registration is FREE
|
Please login or register to view this content. Registration is FREE
vangogh is offline
Reply With Quote
View Public Profile Visit vangogh's homepage!
 
Old 08-28-2006, 11:51 PM Re: Extranenous http://www in front of strings
funkdaddu's Avatar
Web Design Snob

Posts: 635
Trades: 0
+1 to vangogh's post. It's better to just hard-code it in HTML. There's no need for JS there.
funkdaddu is offline
Reply With Quote
View Public Profile Visit funkdaddu's homepage!
 
Reply     « Reply to Extranenous http://www in front of strings
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off





   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML



Page generated in 0.12314 seconds with 12 queries