PDA

View Full Version : Linking to something in a Virtual Page?



TrueKnight
06-18-2007, 01:38 PM
1) Script Title: Virtual Pagination

2) Script URL (on DD): http://www.dynamicdrive.com/dynamicindex17/virtualpagination.htm

3) Describe problem: I want to be able to "Bookmark" or "Link to an Anchor" within a Virtual Page. Can this be done? Say I have something on page 3 of 10 that I want to be able to link to from another part of my site...can I do it? How?

Thanks

alexjewell
06-18-2007, 03:13 PM
Please don't ask the same question in two different places.

For people answering this question, the first question was asked here:
http://www.dynamicdrive.com/forums/showthread.php?t=21836

TrueKnight
06-22-2007, 02:15 PM
alex,
your suggestion in the other thread did not work...


let's keep this question here it's more apprpriate. Sorry about the double posts...I was a newb to the board. It won't happen again! :)

anyway, can someone pease help me with my question?

TrueKnight
06-24-2007, 07:55 AM
Still no help? Anyone please?

jscheuer1
06-24-2007, 05:46 PM
Use the:


instance.showpage(page_number)

as documented on:

http://www.dynamicdrive.com/dynamicindex17/virtualpagination_ref.htm

in conjunction with this javascript 'get' function:


<script type="text/javascript">
function getQval(n, m) {
/*my n=name, m=searchString(optional)*/
if(!arguments[0]||typeof n!='string')
return null;
var r=new RegExp('[?&;]'+n+'=([^&;#]*)'), m=arguments[1]?m:location.search;
return (m=r.exec(m))? unescape(m[1]) : null;
}
</script>

So, you would have something like (on another page):


<a href="some_page.htm?page=3">Goto Virtual Pagination Page, page 4</a>

Then on the virtual pagination page (some_page.htm in this example), have:


<script type="text/javascript">
function getQval(n, m) {
/*my n=name, m=searchString(optional)*/
if(!arguments[0]||typeof n!='string')
return null;
var r=new RegExp('[?&;]'+n+'=([^&;#]*)'), m=arguments[1]?m:location.search;
return (m=r.exec(m))? unescape(m[1]) : null;
}
if(getQval('page'))
instance.showpage(getQval('page')*1)
</script>

Just put it after the initialization of the virtual page. Also, the instance would need to be the name of the variable used to initialize the virtual content in the first place.

Like, if using the first demo content:


<!-- Initialize Demo 1 -->
<script type="text/javascript">
var gallery=new virtualpaginate("virtualpage", 1)
gallery.buildpagination("gallerypaginate")
</script>
<script type="text/javascript">
function getQval(n, m) {
/*my n=name, m=searchString(optional)*/
if(!arguments[0]||typeof n!='string')
return null;
var r=new RegExp('[?&;]'+n+'=([^&;#]*)'), m=arguments[1]?m:location.search;
return (m=r.exec(m))? unescape(m[1]) : null;
}
if(getQval('page'))
gallery.showpage(getQval('page')*1)
</script>

Remember, numbering in javascript usually begins with 0. In this case that means that page 1 is 0, page 2 is 1, etc. So to get page 3 you would use:


<a href="some_page.htm?page=2">Goto Virtual Pagination Page, page 3</a>

jscheuer1
06-24-2007, 06:32 PM
I looked into it a little more, and although my first example works, to really get the effect I think we are looking for, this would be better:


<!-- Initialize Demo 1 -->
<script type="text/javascript">
var gallery=new virtualpaginate("virtualpage", 1)
gallery.buildpagination("gallerypaginate")

function getQval(n, m) {
/*my n=name, m=searchString(optional)*/
if(!arguments[0]||typeof n!='string')
return null;
var r=new RegExp('[?&;]'+n+'=([^&;#]*)'), m=arguments[1]?m:location.search;
return (m=r.exec(m))? unescape(m[1]) : null;
}
if(getQval('page')){
if(gallery.flatviewpresent)
gallery.flatviewlinks[gallery.currentpage].className=""
gallery.currentpage=getQval('page')*1;
gallery.navigate(getQval('page')*1);
}
</script>

Notes: I combined the initialization and the get code into one script tag block. The key here is that page is the name of the variable passed with the href from the other page linking to this script, and gallery is the variable used to initialize this instance of the script.

TrueKnight
06-24-2007, 08:31 PM
I don't know what I am doing wrong...but I used the script as you suggested above and it still does not work.... :(

jscheuer1
06-25-2007, 03:03 AM
Well, it is working here so it's possible. There are however at least several ways that the basic script can be setup. I only tested this with the supplied demo, and at that, only with the first of the 5 supplied demos. Is yours like the first demo? Are you trying this with more than one instance of the script? Anyways, a link to your page would help me sort things out.

Here's a working demo, if that'll help you:

http://home.comcast.net/~jscheuer1/side/v_page/

TrueKnight
06-26-2007, 10:06 AM
Got it to work! Thanks for your help! :)

ata_gp
08-22-2007, 12:14 PM
I've tried to use this method: <a href="some_page.htm?page=2">Goto Virtual Pagination Page, page 3</a> in a flash button, with the following code:


on (release) { getURL("some_page.htm?page=2");}

But it doesn't work, I don't know why 'cause it works fine trough html.

Thanks in advance

jscheuer1
08-22-2007, 02:32 PM
I've tried to use this method: <a href="some_page.htm?page=2">Goto Virtual Pagination Page, page 3</a> in a flash button, with the following code:


on (release) { getURL("some_page.htm?page=2");}

But it doesn't work, I don't know why 'cause it works fine trough html.

Thanks in advance

As long as it is loading that page with that exact URL and query string, it should work. If not, it is a problem with the Flash (action script) command itself. Perhaps the ? or = characters need to be escaped somehow. Since I am no Flash expert, unless one chimes in here, or what I have said 'gets it' for you, try asking in the Flash forum.