How do I modify the displayed browser url?
A Flash Developer Resource Site

Results 1 to 9 of 9

Thread: How do I modify the displayed browser url?

  1. #1
    Senior Member
    Join Date
    Feb 2008
    Posts
    107

    How do I modify the displayed browser url?

    I have a site that consists of multiple html pages that parallel the flash site's pages - for SEO purposes. Both sets of pages use the same XML source (to avoid any appearance of cloaking).

    I would like to modify the browser URL to reflect the currently displayed state. I've already got the other direction covered - when the user arrives via a deep-link URL, I pass in Flashvars using SWFObject.

    I found SWFAddress, but it forces a "#" sign into the displayed URL, and there doesn't seem to be any way to turn it off. I realize it's intended to be used with named anchors, but that approach doesn't accommodate what I'm trying to do - I don't want just a single HTML page with all site content on it, using named anchors to jump around. That seems to me to be contrary to best practices - rather I should have a single HTML page for each state in my Flash site.

    The approach I'm embarking on will actually use a single PHP page which will generate a custom HTML page when requested - e.g.

    mysite.com/index.php?page=about

    will load the "about" state text (if requested by Google) or direct to the "about" page of the SWF (if the user has Flash/javascript).


    Is it possible to change th displayed browser URL through some method that's a bit more flexible than SWFAddress?

  2. #2
    Mod cancerinform's Avatar
    Join Date
    Mar 2002
    Location
    press the picture...
    Posts
    13,448
    You can create a cookie in php or a shared object in flash with the browser url and when you are in flash you can call the cookie information.
    - The right of the People to create Flash movies shall not be infringed. -
    | www.Flashscript.biz | Flashscript Biz Classes/Components |

  3. #3
    Senior Member
    Join Date
    Feb 2008
    Posts
    107
    Hmm - not sure I understand how that would work. How does saving a cookie (or shared object) translate into changing what's displayed in the browser url?

  4. #4
    Mod cancerinform's Avatar
    Join Date
    Mar 2002
    Location
    press the picture...
    Posts
    13,448
    I probably misunderstood . Where do you want to change the URL, in the php page?
    - The right of the People to create Flash movies shall not be infringed. -
    | www.Flashscript.biz | Flashscript Biz Classes/Components |

  5. #5
    Will moderate for beer
    Join Date
    Apr 2007
    Location
    Austin, TX
    Posts
    6,801
    Do you mean that you want to have a swf which if it was embedded in this page would change the displayed url from "http://board.flashkit.com/board/showthread.php?t=767321" to something else?

    I sure hope that's not possible. Imagine the field day phishers would get out of that, when evilbastards.com (no offense to whoever owns that) can post a page that looks like it came right from bankofamerica.com.

  6. #6
    Senior Member
    Join Date
    Feb 2008
    Posts
    107
    Yup - that's what I'm thinking of. You're right - prone to evil. My uses are less nefarious - I just want the user to be able to bookmark a state of the SWF and return there later.

    I know current deep-linking vogue uses named anchors - I was hoping to avoid that approach, because you're still working with the same base HTML page. I want to deliver a different HTML page for each page/state IF the user (Google) doesn't have Javascript/Flash.


    What I've worked out is pretty slick. I have a single PHP page (index.php) which, depending on the query string, will load the relevant state (title, body text, subnav) from an XML file. So "index.php?page=about" sets the page title to About and loads the XML body text for the About page. The SWF for the site uses the same source XML for its body text for each state - so no worries about cloaking, and no need to enter the content twice.

    Google can crawl and index the whole HTML version of the site, and users following Google links to particular pages will cause the PHP file (if they have Javascript/Flash) to pass a flashvar to SWFObject so the Flash file loads the relevant (e.g. "About") state.

    The only problem is, if the user comes in on "index.php?page=about", when they start clicking around the SWF, the url will remain "page=about". Not a deal-killer, but not perfect - it'd be nice if it changed to the currently chosen state.


    I think you can do what you fear using SWFAddress - can't you? Or Javascript anyway - I think you can rewrite the displayed URL. You can certainly rewrite the part after the domain.

  7. #7
    OOP is one letter from OOPS kortex's Avatar
    Join Date
    Aug 2005
    Location
    New Hope, PA
    Posts
    2,668
    The common way that what you are talking about (sometimes known as smart URLs, the SEO friendly ones), is by using the Apache rewrite module (takes you to a page other than that displayed in the address bar).

    The ability to change the URL with JavaScript is done via the window.location property, but setting this value will actually take you to that url (I have never seen it be able to change the displayed url without actually taking you to it)

    I am not familiar with SWFAdrress, but the only way I am aware of displaying any other address in the address bar is the Mod Rewrite.

    Any one else know more about this?
    Jeremy Wischusen
    Flash - Flex - LAMP - Web Developer Purple Inc
    AS OOP FAQ-Best Practices Thread | Flashkit OOP Tutorials | Purple Inc (day job) | Blog


  8. #8
    Senior Member
    Join Date
    Feb 2008
    Posts
    107
    SWFAddress uses javascript top.location.hash to change the displayed URL - it doesn't redirect, just changes what is displayed.

    At least that's how I think it works - the javascript is so optimized it's pretty much indecipherable.

    Still it's an interesting approach - google SWFAddress if you want to dig any deeper.

  9. #9
    OOP is one letter from OOPS kortex's Avatar
    Join Date
    Aug 2005
    Location
    New Hope, PA
    Posts
    2,668
    Ok I took a look at the demo for SWFAddress. It is using anchor names (the same idea that allows you to link to a specific location within a page). For example:
    http://asual.com/swfaddress/samples/flash/#/contact/

    Note the # character. So that would allow you to change the displayed URL without actually leaving the page since the browser thinks you are linking to a named anchor within the page. Kind of a neat trick.
    Jeremy Wischusen
    Flash - Flex - LAMP - Web Developer Purple Inc
    AS OOP FAQ-Best Practices Thread | Flashkit OOP Tutorials | Purple Inc (day job) | Blog


Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  




Click Here to Expand Forum to Full Width

HTML5 Development Center

Poll by Flashkit.com