?
Solved

different starting page in a website

Posted on 2012-03-15
2
Medium Priority
?
392 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 2000 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

Get real performance insights from real users

Key features:
- Total Pages Views and Load times
- Top Pages Viewed and Load Times
- Real Time Site Page Build Performance
- Users’ Browser and Platform Performance
- Geographic User Breakdown
- And more

Question has a verified solution.

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

FAQ pages provide a simple way for you to supply and for customers to find answers to the most common questions about your company. Here are six reasons why your company website should have a FAQ page
There’s a good reason for why it’s called a homepage – it closely resembles that of a physical house and the only real difference is that it’s online. Your website’s homepage is where people come to visit you. It’s the family room of your website wh…
The viewer will learn how to dynamically set the form action using jQuery.
The viewer will get a basic understanding of what section 508 compliance can entail, learn about skip navigation links, alt text, transcripts, and font size controls.
Suggested Courses

770 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