Solved

different starting page in a website

Posted on 2012-03-15
2
390 Views
Last Modified: 2013-11-19
Hi,

How can I have users make a page the start page within a website. For example, we have a several tabs (category A, category B, ...). One user wants their start page A the other B when they visit our website. I want to put a button or link saying "Make this page my starging page". Once they click that link, whenever they visit our website, category B will be the first page they see. I understand if they clear cache, it will be gone.

Thank you.
0
Comment
Question by:Naratech
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 7

Accepted Solution

by:
micropc1 earned 500 total points
ID: 37727597
If the page uses some kind of logon framework I would store the information in their user profile, then load the page the next time they log on, but since this question is under Javascript/Web Dev I'm assuming you are looking for a Javascript solution...

You could use cookies and redirect them based on their saved selection. Using the example code from W3Schools (http://www.w3schools.com/js/js_cookies.asp) you could do something like...

var setCookie = function (c_name,value,exdays) {
	var exdate=new Date();
	exdate.setDate(exdate.getDate() + exdays);
	var c_value=escape(value) + ((exdays==null) ? "" : "; expires="+exdate.toUTCString());
	document.cookie=c_name + "=" + c_value;
};

var getCookie = function (c_name) {
{
var i,x,y,ARRcookies=document.cookie.split(";");
for (i=0;i<ARRcookies.length;i++)
{
  x=ARRcookies[i].substr(0,ARRcookies[i].indexOf("="));
  y=ARRcookies[i].substr(ARRcookies[i].indexOf("=")+1);
  x=x.replace(/^\s+|\s+$/g,"");
  if (x==c_name)
    {
    return unescape(y);
    }
  }
};

var startPage=getCookie("startPage");

//if a start page cookie is set, redirect the user
if (startPage!=null && startPage!="") {
	location.href = startPage;

//otherwise go to the default page
} else {
	location.href = "defaultPage.html";
}

Open in new window


and to set the cookie you would do...

setCookie("startPage",startPage,365);

Open in new window

0
 

Author Closing Comment

by:Naratech
ID: 37727713
Thank you. I think I can make this work on my website.
0

Featured Post

MIM Survival Guide for Service Desk Managers

Major incidents can send mastered service desk processes into disorder. Systems and tools produce the data needed to resolve these incidents, but your challenge is getting that information to the right people fast. Check out the Survival Guide and begin bringing order to chaos.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article will inform Clients about common and important expectations from the freelancers (Experts) who are looking at your Gig.
Dramatic changes are revolutionizing how we build and use technology. Every company is automating, digitizing, and modernizing operations. We need a better, more connected way to work together as teams so we can harness the insights from our system…
This tutorial walks through the best practices in adding a local business to Google Maps including how to properly search for duplicates, marker placement, and inputing business details. Login to your Google Account, then search for "Google Mapmaker…
This tutorial will teach you the core code needed to finalize the addition of a watermark to your image. The viewer will use a small PHP class to learn and create a watermark.

688 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question