I was wondering if anyone knew if this would be a search engine friendly link?
<a class="current"href="javascript:loadintoIframe('myframe',
'home!.html')" onClick="return handlelink (this)">Home</a>
I was wondering if anyone knew if this would be a search engine friendly link?
<a class="current"href="javascript:loadintoIframe('myframe',
'home!.html')" onClick="return handlelink (this)">Home</a>
It definitely wouldn't. Never write links like that. Instead, try:You evidently haven't tested your site in a non-Javascript browser.Code:<a class="current" href="home%21.html" onclick="loadintoIframe('myframe', this.href); return handlelink(this);">Home</a>
Twey | I understand English | 日本語が分かります | mi jimpe fi le jbobau | mi esperanton komprenas | je comprends français | entiendo español | tôi ít hiểu tiếng Việt | ich verstehe ein bisschen Deutsch | beware XHTML | common coding mistakes | tutorials | various stuff | argh PHP!
I agree with Twey. I also think that, depending upon the actual structure of the page and iframe setup, adding a target attribute for the non-javascript link might be good:
And, if the onclick event doesn't do anything all that special, it could be skipped:Code:<a class="current" href="home%21.html" target="myframe" onclick="loadintoIframe(this.target,this.href);return handlelink(this);">Home</a>
Code:<a class="current" href="home%21.html" target="myframe">Home</a>
- John________________________
Show Additional Thanks: International Rescue Committee - Donate or: The Ocean Conservancy - Donate or: PayPal - Donate
Twey and John,
Thank you for the replies. I have tried this page with Javascript disabled and it is so sad that I put a "Things don't look right button" to load a non-Javascript page. Is there non-javascript code to load a different page when Javascript is not enabled?
Using "!" in "home!.html" may have been a poor choice of characters with more then one home.html. Why the "%21"?
The onclick event leaves the active link a different color and I would like to keep it.
Twey, This code works except it refreshes the entire page. I was using iframes to avoid just that. Is there a fix?
Code:<a class="current" href="home%21.html" onclick="loadintoIframe('myframe', this.href); return handlelink(this);">Home</a>
John, This works except it also opens a new browser window and loads my page there too. Your second example only loads my page to a new browser window but I need the onclick.
I am using a Javascript script to adjust the height of the iframe to fit the page. Is that messing up these links?Code:<a class="current" href="home%21.html" target="myframe" onclick="loadintoIframe(this.target,this.href);return handlelink (this);">Home</a>
Thanks for your help. Any further input would be appreciated.
Mike (AKA newbie)
Last edited by mdconnor; 01-29-2007 at 07:32 PM. Reason: remove test code
No, but you need to include a "href" property for it to be a link, and not an bookmark.I am using a Javascript script to adjust the height of the iframe to fit the page. Is that messing up these links?
Try this:
If JavaScript is disabled though, the height/width script won't work.Code:<a href="#" class="current" href="home%21.html" target="myframe" onclick="loadintoIframe(this.target,this.href);return handlelink (this);">Home</a>
Again on the URLS: Notice how if you every type in a space to a search engine, it will replace it with %20, which is how the browser reads spaces. They would definitely cause problems, so escaping the characters would be the most logical route.
- Mike
Mike,
Thanks for the reply, Your link opens a new browser window.
Are you saying that using "!" in a URL is bad?
Twey,
Your code actually opened home.html by itself in my browser window rather then in the iframe after taking out.
Forgot it was in there.Code:<SCRIPT LANGUAGE="JavaScript"> <!-- if (top == self) self.location.href = "index.html"; // --> </SCRIPT>
Mike
I assumed your handlelink() function returned false. If not, change it so it does.Twey, This code works except it refreshes the entire page. I was using iframes to avoid just that. Is there a fix?
[...]
Your code actually opened home.html by itself in my browser window rather then in the iframe after taking out.This is a very sub-standard solution. Design your non-Javascript page first, then add Javascript to implement the various effects, testing with and without Javascript all the while to make sure that nothing is being interfered with and the page still looks good without Javascript. Never design a page that relies upon Javascript.Is there non-javascript code to load a different page when Javascript is not enabled?There are characters that are not allowed in URLs. These must be escaped as one (or more, for multi-byte encodings) %XX , where XX is a two-digit hexadecimal representation of the character.Using "!" in "home!.html" may have been a poor choice of characters with more then one home.html.myframe should be replaced with the name of your frame.Your second example only loads my page to a new browser window but I need the onclick.
Twey | I understand English | 日本語が分かります | mi jimpe fi le jbobau | mi esperanton komprenas | je comprends français | entiendo español | tôi ít hiểu tiếng Việt | ich verstehe ein bisschen Deutsch | beware XHTML | common coding mistakes | tutorials | various stuff | argh PHP!
Oh, I assumed the OP had already named his frame "myframe". Sorry, I misread the post.myframe should be replaced with the name of your frame.
- Mike
Twey,
I took the "handlelink() function" out completely and it still does not work.
The name of my frame is "myframe".
The only JavaScript that is a real problem when JavaScript is not working is the iframe resizing. not sure how to get around that one but to have a button to another non javascript page.
The only link that works properly is my original link for some reason. It is not worth figuring out as I have already placed a friendly link in another location on the page.
I am still not sure why the "%21" is in the code above. The "!" is a valid URL character.
I appreciate all of your help. It is obvious that you guys are beyond me when it comes to JavaScript but we all have to start somewhere and I am trying.
Thanks again,
Mike
Hm, you're right. My error, I'm too used to living by the standards of the deprecated escape()Originally Posted by RFC1738
The handler must return false. If you remove the handlelink() function, you must explicitly return false; at the end of the handler.I took the "handlelink() function" out completely and it still does not work.
Twey | I understand English | 日本語が分かります | mi jimpe fi le jbobau | mi esperanton komprenas | je comprends français | entiendo español | tôi ít hiểu tiếng Việt | ich verstehe ein bisschen Deutsch | beware XHTML | common coding mistakes | tutorials | various stuff | argh PHP!
Bookmarks