Results 1 to 10 of 10

Thread: Website survey form

  1. #1
    Join Date
    Nov 2011
    Location
    Cider Region
    Posts
    1,132
    Thanks
    158
    Thanked 3 Times in 3 Posts

    Default Website survey form

    I have a website survey form which is here http://www.theremotedoctor.co.uk/survey_form.html

    Its goal is to pop up when the customer leaves my site.
    I have this code.
    Code:
    <script type="text/javascript">
    
    window.onunload = unloadPage;
    
    function unloadPage()
    
    {
    
    alert("YOUR MESSAGE HERE");
    
    }
    
    </script>
    But i am not sure where i need to put it.
    Please can you help.

    Thanks

  2. #2
    Join Date
    Jul 2008
    Location
    Derbyshire, UK
    Posts
    3,033
    Thanks
    25
    Thanked 599 Times in 575 Posts
    Blog Entries
    40

    Default

    Best practise now is to put scripts before the closing </body> tag.
    Focus on Function Web Design
    Fast Edit (A flat file, PHP web page editor & CMS. Small, FREE, no database!) | Fast Edit BE (Snippet Manager) (Web content editor for multiple editable regions!) | Fast Apps

  3. #3
    Join Date
    Nov 2011
    Location
    Cider Region
    Posts
    1,132
    Thanks
    158
    Thanked 3 Times in 3 Posts

    Default

    Hi,

    Ive now added it but i dont see it working when i leave the site.
    Did i do something wrong,please take a look.

    http://www.theremotedoctor.co.uk/

  4. #4
    Join Date
    Jul 2008
    Location
    Derbyshire, UK
    Posts
    3,033
    Thanks
    25
    Thanked 599 Times in 575 Posts
    Blog Entries
    40

    Default

    I don't see it in the source. Have you put it in an external file?
    Focus on Function Web Design
    Fast Edit (A flat file, PHP web page editor & CMS. Small, FREE, no database!) | Fast Edit BE (Snippet Manager) (Web content editor for multiple editable regions!) | Fast Apps

  5. #5
    Join Date
    Nov 2011
    Location
    Cider Region
    Posts
    1,132
    Thanks
    158
    Thanked 3 Times in 3 Posts

    Default

    Its at the bottom,see example below.

    Code:
      <script type="text/javascript">
      document.getElementById("si" + "mple" + "_spc").value = "51892726990368-51892726990368";
      </script>
    </form>
    <script type="text/javascript">
    
    window.onunload = unloadPage;
    
    function unloadPage()
    
    {
    
    alert("YOUR MESSAGE HERE");
    
    }
    </script>
    </body>
    </html>

  6. #6
    Join Date
    Jul 2008
    Location
    Derbyshire, UK
    Posts
    3,033
    Thanks
    25
    Thanked 599 Times in 575 Posts
    Blog Entries
    40

    Default

    I am looking in the http://www.theremotedoctor.co.uk/ page you posted - at the source code. The code isn't there.
    Focus on Function Web Design
    Fast Edit (A flat file, PHP web page editor & CMS. Small, FREE, no database!) | Fast Edit BE (Snippet Manager) (Web content editor for multiple editable regions!) | Fast Apps

  7. #7
    Join Date
    Nov 2011
    Location
    Cider Region
    Posts
    1,132
    Thanks
    158
    Thanked 3 Times in 3 Posts

  8. #8
    Join Date
    Jul 2008
    Location
    Derbyshire, UK
    Posts
    3,033
    Thanks
    25
    Thanked 599 Times in 575 Posts
    Blog Entries
    40

    Default

    I'm a little confused by what you're trying to do.

    I'm guessing you're thanking them for completing the survey once they leave the page?

    In that case, the message alert is working - just change the alert to your thank you message.
    Focus on Function Web Design
    Fast Edit (A flat file, PHP web page editor & CMS. Small, FREE, no database!) | Fast Edit BE (Snippet Manager) (Web content editor for multiple editable regions!) | Fast Apps

  9. #9
    Join Date
    Nov 2011
    Location
    Cider Region
    Posts
    1,132
    Thanks
    158
    Thanked 3 Times in 3 Posts

    Default

    No,
    When they leave any page on my site then the script would operate and the survey form would be shown.
    I have added the script here http://www.theremotedoctor.co.uk/acc...llto=selection as this is where it should be but still nothing.

    The script needs to be on every page of mine so when leaving the survey is then shown.

  10. #10
    Join Date
    Jul 2008
    Location
    Derbyshire, UK
    Posts
    3,033
    Thanks
    25
    Thanked 599 Times in 575 Posts
    Blog Entries
    40

    Default

    So it's a redirect script you're after? You need more than an alert then. Try Googling for something like "confirm and redirect on page exit". I'm not sure how successful you'll be with a default JS confirm window though. I would have thought that on confirming page exit, you're cutting the connection with the browser so further functions/events (the redirect) wouldn't fire. I imagine you'd need to look for a custom/pseudo confirm popup? You might be able to find something by way of a jQuery plugin but I'm not sure.

    From a user experience perspective, I would recommend that you don't try to hijack the user's browser. Typically, when people want to leave a site, they want to do just that and not be hindered by obtrusive popups unless they provide a useful function, such as clearing cookies or reminding that unsubmitted form data may be lost. It will likely annoy people and leave negative feelings (and could deter them from visiting the site again).
    Focus on Function Web Design
    Fast Edit (A flat file, PHP web page editor & CMS. Small, FREE, no database!) | Fast Edit BE (Snippet Manager) (Web content editor for multiple editable regions!) | Fast Apps

Similar Threads

  1. Survey Pop Up
    By hector jaime in forum Looking for such a script or service
    Replies: 1
    Last Post: 04-03-2010, 01:01 AM
  2. Form Code without using a website like Freedback?
    By ModernRevolutions in forum HTML
    Replies: 7
    Last Post: 01-14-2009, 08:31 AM
  3. Submit Form on another Website/hosting.
    By vinriver in forum JavaScript
    Replies: 1
    Last Post: 12-06-2008, 08:35 PM
  4. Survey
    By crimsonsmeagol in forum JavaScript
    Replies: 5
    Last Post: 06-24-2008, 02:54 AM
  5. Survey Help
    By Amyunimus in forum HTML
    Replies: 0
    Last Post: 07-24-2007, 02:11 PM

Bookmarks

Posting Permissions

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