Hello, So after looking around frantically for something I don't think exists, I figured I've give you guys a shout. Everyone is familiar with internal page link jumps where you click a link and it takes the html to a predefined spot on the page. An example would look like this. <a href="#jumphere">clickme</a> <a name="jumphere"></a> HTML: If you were to click "clickme" in the above it would take the page to the spot that is referenced by name="jumphere" in the html. What I am trying to do is work something out where when you click "clickme" it jumps to a predefined height marker of the page. Like click it and it jumps the page down to 800px from the top. Any suggestions as to how to go about doing this??? I'll post it in javascript also, perhaps those geeks can tell me how to jump to a predefined height using <body onload="xxx"> Thanks for reading, and thanks in advance for your assistance getting this figured out.
I'm sure you can do this with JavaScript...I'm not too sure how (only know the basics of JS), but i'm sure it wouldn't take long to find out.
First off, you want to use the ID attribute on the link; second, why do you want to jump to a pre-defined point anyway? Most people will find this confusing as hell. Now, if you want to have the page scroll smoothly when the internal link is clicked, that's well within the realm of possibility, as noted here: http://www.sitepoint.com/article/scroll-smoothly-javascript
Thanks for the link, that's a pretty cool effect that I'll store away for later but it's really not what I'm working for. I use both id and name on all jumps like that, my coding above is just a 2 second hack. Here's a good example of why I'm looking to do this. Say you run zip submits from affiliate companies. These guys have these pages of crap that people really won't submit to because they are poorly laid out, ugly as all getup, bad text / information or whatever. If I can make that page jump to just the place where people can enter the zip and click the submit button from an iframe I can build a page to my likings and get the visitors to fill out a form for the affiliate offer. Some promotions allow you to use their form on your page ... 99% don't or the AM's aren't smart enough to ask them how to best accomplish this.
So what you're saying is you want the link on one page to jump automatically to a section of another page? That's easy as dirt to do with HTML. Just put the ID attribute you want to use as the target on one page, and then link to it with the anchor element on the other page. For example, if you have a page that has a section about puppies, you'd use an ID attribute with the value of "puppies" for that part of the page. Like so: <div id="puppies"> ... content about puppies </div> Code (markup): Then on your other page, you'd link to it like so: <a href="/link/to/page.html#puppies">Link to section of page about puppies</a> Code (markup): Of course, "/link/to/page.html" would be the URL to the page in question, but you're still going to need #puppies (or whatever the ID attribute's value is) in order to jump straight to that part of the page.
Yep, I understand how to jump inside a page to a location marked by #section. The issue is that I don't control the other page, it's someone else's on someone else's server. I can't just dropt a <a name="puppies"> or <div id="puppies"> anywhere on the page because I don't have access. That's why I'm trying to drop the page to a predetermined height (like 800px from the top) when it loads in my iframe. You following me? Thanks for the help though.
Ok. Late nights can addle the ole' noggin a bit at times. Anyway, I don't think what you want to do is going to be possible, especially when you consider things like the text resizing in the user's window. You *might* be able to do it, but that would require some very complex and advanced JavaScript (assuming I'm right).
Javascript or some other script which can do regular expressions. You'd still have to be able to tell it what to look for (how do YOU know what part of the page is appropriate? Do you look for a particular word or phrase? Something like that. If it's based on the content alone no, it can't be done with HTML because HTML consists of tags which wrap content, but doens't actually know what's inside the content. Possibly microformats or RDFa when it's actually truly OUT could do something here, where the tags state what the content is in a machine-readable format... but then, if these people can't bother to type correctly or do a simple layout, asking them to add meta data would be just as impossible : )