jquery mobile multi-page internal hyperlinking - jquery-mobile

This appears to be pretty basic but I can't figure it out.
Using a jqm multipage template, I'm trying to allow users to jump from a link one page (id='page1') directly to an image in another page (id='page2').
FIDDLE
It appears I am constrained, by html hyperlinking rules and jqm, to this:
<a href='#page2'>go to image on p2</a>
... which of course jumps the user to the top of page2.
But that's not what I want. I want the user to jump directly to the IMAGE, which is close to the bottom of page2, tagged like so:
<img id='image-id'>
But tagging the link with the image's id (not the page's id), i.e. tagging it like this
<a href='#image-id'>go to image on p2</a>
doesn't work.
I get the feeling I'm missing something very obvious, but can't figure it out.
Any suggestions? Or is this not possible?

I've got a different problem but found this question in my travels... thought I would add an extract from the jquery mobile page:
http://demos.jquerymobile.com/1.4.5/navigation-linking-pages/
Note: You cannot link to a multipage document with Ajax navigation active because the framework will only load the first page it finds, not the full set of internal pages. In these cases, you must link without Ajax (see next section) for a full page refresh to prevent potential hash collisions. There is currently a subpage plugin that makes it possible to load in multi-page documents.

Related

Display external website page in asp .net mvc 5

I am building a website for a class project using ASP NET MVC 5, wherein I need a section of the website to display a page from a different website. The goal is to somehow embed that page in my view, so UI interactions are still possible with the embedded page, as if the page was visited directly in the browser (the end effect is that the page is rendered and allows interaction but my website theme always stays around it)
I know one way to do it is to just put it inside an iframe in my View. But I want to know if there is a different solution. My instructor suggested using partial views, but I can't figure out how to achieve the same result. Can anyone suggest a different way to achieve this ? Also, what would be the right way to do this in terms of security (I believe iframe is), but I want to know other's opinion ?
Thanks.
I suggest you use a sandboxed IFrame e.g.
http://www.html5rocks.com/en/tutorials/security/sandboxed-iframes/
<iframe sandbox="allow-same-origin allow-scripts allow-popups allow-forms"
src="https://blah.com/index.html"
style="border: 0; width:130px; height:20px;">
</iframe>
You can tweak how much power the content in the Iframe has (i.e. can it run scripts).
I guess you could also look at using a partial view. My guess is you'd need to use a WebClient instance to download the HTML source of the target webpage, and then pass that HTML into a partial view. But I don't see how any script tags would render correctly for you, which means the page would not be interactive.

How can I mask the URL path to a webpage within my website?

I have a website with a default home page of index.html, let's call the website: www.brianbauer.com ( that is my name BTW).
www.brianbauer.com operates something like a "treasure hunt". by clicking on various hot-spots on each HTML page access via brianbauer.com, you get redirected to the next html page. this continues for some period of user-clicks. One of the ideas is that on each visit, it is not obvious how the user reached a specific webpage. all they know is that they kept clicking and ended up at some final HTML page. but every click that brings up a new HTML page, still shows "http://www.brianbauer.com" in the Address bar. This is a game, nothing "wrong" going on here.
1. All of the HTML pages are owned by me, and I authored them all.
2. No illegal or unscruptulous activty of any kind going on.
3. all HTML pages in scope are under the root domain of brianbauer.com
the idea is that as users look at pictures and read a narrative, they make choices. a typical webpage might have 4 choices. depending on your choice, the next HTML page you see is determined.
I have created site maps that are basically decision trees.
think of it like a digital corn-maze. It's important that the full URL path to the current HTML page that they are looking at is masked, and should only show "www.brianbauer.com". it is true that someone more sophisticated could look at sourcecode, record their screen, keep notes, etc. but the mask will accomplish 90% of my goal.
as for being able to bookmark a certain webpage that they have "discovered"? the whole point is that they should not be able to....
I am NOT trying to mask my domain, that is easy. I am trying to simply maske what appears in the Address bar as users hit HTML pages which are children of that domain.
Thank you for the help.
Brian
There is something called CNAME cloak it might be one option.
Another option could be using ajax and replace content of the page.

jQuery mobile: URL query string does not change

I'm playing around with jQuery Mobile and ran into some (for me) strange behavior.
I have a bunch of links each pointing to the same jQM page, #otherpage, but with different values for the URL query string, like #otherpage?q=foo, #otherpage?q=bar, and so on. The change to the other page works fine but the query string sticks between clicks, so if I first click the link to #otherpage?q=foo, and then goes back to the first page, all subsequent page changes to #otherpage will have q=foo, no matter what the currently clicked link's href says.
jsFiddle didn't seem to have support for jQM so I put an example here: http://cpak.se/dump/location-search-test.html
I've tried this in Chrome and Safari on Mac.
I use the query string to pass simple data between pages since I have other code hooked into the pagechange events, that is more or less unaware of what earlier code might have done. If I can't get this working I'll have to find another way to pass data around... :P
Cheers!
/Christofer
Disabling jQm seems to be the easiest solution for updating the url parameters correctly in the browser. E.g. adding data-ajax="false" in the link anchor and not using $.mobile.changePage.
<a href="#page?id=1" data-ajax="false">
In a dynamic app modify the value of href beforehand.
I've looked up for this issue because it seems a little bit weird indeed. There is a open issue about this: https://github.com/jquery/jquery-mobile/issues/2859
Atm jQuery Mobile doesn't recommend using query parameters:
We don't currently support query parameters as part of the hash
fragment, though this is something that's been discussed frequently
internally and is on the feature request list.
They advise to use a plugin like:
https://github.com/jblas/jquery-mobile-plugins/tree/master/page-params
https://github.com/azicchetti/jquerymobile-router
However, there is a workaround since the data-url of the active page in the DOM DOES change, you can retrieve this with $(".ui-page-active").attr("data-url"); I've tested this on your website and it gave me all 3 uniques URLs
jQuery Mobile by default does not allow passing query-string parameters to internally linked pages. Check-out the very bottom of this documentation page (the second bullet from the bottom of the page): http://jquerymobile.com/demos/1.0rc3/docs/pages/page-navmodel.html
jQuery Mobile does not support query parameter passing to
internal/embedded pages but there are two plugins that you can add to
your project to support this feature. There is a lightweight page
params plugin and a more fully featured jQuery Mobile router
plugin for use with backbone.js or spine.js.

jquery mobile - requesting multi-page page via changePage

From the index page of the site, I am loading another page which has 3 divs with the data-role of page.
However, jquery mobile only appends one of the pages to the dom.
I presume the changePage function is grabbing the first div with a data-role of page and inserting it. I wonder if there is a way to get it to insert all the divs with a data-role of page or dialog.
Any help more than appreciated.
thanks
What you are trying to do is currently not possible with JQM, as only the first page from a multipage gets loaded into the DOM.
I would point point you to a link in the JQM docs that would explain this behavior, but there isn't one... I already filed this as issue on Github, so that the Docs at least make clear what you can do and what does not work with multipages.
As I'm stuck with the same issue I started writing a plugin to be able to load multipages (among other things). I still have a few things to sort out, but when it's working I can send you the link.
You can use a "subpage" plugin to get the behavior you desire. Basically one page contains a bunch of subpages, which all get loaded into DOM. The pattern would be:
<div data-role="page">
<div data-role="subpage">
</div>
<div data-role="subpage">
</div>
<div data-role="subpage">
</div>
</div>
The project is available here: https://github.com/ToddThomson/jQuery-Mobile-Subpage-Widget.
I've personally been having problems with this plugin, but I think for simple scenarios, it works fine.
Also, there is no documentation for it. For example, I still don't know the proper way to call $.mobile.changePage() with this plugin. :)
According to JQM at this page:
"jQuery Mobile currently only supports loading of single page documents via AJAX. To navigate to a multi page document you must disable ajax on the link by adding the data-ajax="false" attribute. There is also a widget to allow for supporting sub-pages by Todd Thompson available at https://github.com/ToddThomson/jQuery-Mobile-Subpage-Widget"
You can also add rel="external" attribute to the href pointing to Page B.
rel="external" and data-ajax="false" will force JQM to load the entire page as new. Unfortunately, it appears this removes the ability to use a page transition from PageA to PageB.
Example: Page B
I'm now looking to load Page B with JQM methods instead of relying on the automagic mechanisms. It appears you must use single page templating throughout (as recommended) or pagecontainer load method (essentially the same as single page) if you want hashtag transitions within a "single page", after the DOM is initially loaded. For example, link to a single page, listen to "pageinit" of that page, then use pagecontainer("load"). Make sure the subsequent page (the page your're injecting) is not needed as a direct incoming page.

Hard refreshes and SEO

I couldn't find an answer to this on the web. I have a site, where I try to avoid hard refreshes as much as possible. It's a sequences of photos, and upon a user click of a central div, a little page (a RoR partial) loads within that div with a new photo in it.
The user keeps clicking, the photo keeps changing, and the URL of the page never changes. The title of the photo does change though. And so I want the web crawlers to see this...
Is there any advantage to having a hard refresh or not in this scenario? Will the Web Crawlers see the title of the photo in the div, and index my home page? Or at least the url of the inner div?
I hope this makes sense! Thanks!
It all depends on what you mean by a hard refresh. If all of the pictures, and their related data (title etc.) are loaded when the page first loads, and the click is just a javascript event that changes the css a bit to display the next picture then that has no negative effect on SEO. If clicking that link makes an ajax request back to your server to retrieve the image, then it will never get picked up by the search engine web crawler, and will not contribute to SEO.
If you aren't sure if this click is an ajax request, or just a css change, you can look at your html source to figure it out. If all your image tags are in your html source then it's not making an ajax request. If you only see one (or zero) then it is making an ajax request.
If the page title would never change, then there's no benefit. But if you're loading a new image, the page title should change for optimal SEO.
There's a workaround, though. Just make it to where you can access the images specifically with a static page and make sure Google spiders it. You can keep the normal page flow as-is using this method.
Edit: I should add that I had a site that got 60% of it's traffic from Google Image searches, so I'd say you'd definitely want them indexed separately.

Resources