Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8270365
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T06:33:07+00:00 2026-06-08T06:33:07+00:00

i am trying to understand part of javascript code is refer to the code

  • 0

i am trying to understand part of javascript code is refer to the code is:Link, now there is 2 more css files the first contain(sansStyle.css):

body, p, td, ol, ul, select, span, div, input {
    font: .9em/1.1em verdana, geneva, arial, helvetica, sans-serif;
}

the second contain(serifStyle.css):

  body, p, td, ol, ul, select, span, div, input {
        font: 1.1em/1.2em Times New Roman, Times, serif;
    }

my problem is only at a small part at the javascript code that i dont understand, if you take a look at the link and at the javascript part the is:

if (inVal) {
        if (typeof inVal == "string") {
            title = inVal;
        }
        else {
            title = inVal.target.id;
        }
    }
    else {
        title = window.event.srcElement.id;
    }

now i do understand that we refer at the else to the id becouse it got the same value as the title value we need, but the problem is that if its not a string so what is it? and how does it get for example inVal.target.id what is inVal.target is?, and about the window event.srcElement.id what event is it? if can some one please help me understand thoes two i will be very thankful.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-08T06:33:09+00:00Added an answer on June 8, 2026 at 6:33 am

    inVal can be two things it can be a String or it can be a click event.

    1.) inVal can be a string when it gets the title (which is the style I assume) see this line setActiveStylesheet(title)

    If you look closely title will always be a string either form the cookie var thisCookie = cookieVal("style"); or from the getActiveStylesheet() function

    2.) inVal can be a click event as Haynar pointed it out looks at

    allButtons[i].onclick = setActiveStylesheet;
    

    Hence you check if it is a string

        if (typeof inVal == "string") {
            title = inVal; // when it comes form the cookie or getActiveStylesheet()
        }
        else {
            title = inVal.target.id; // it is an event
        }
    

    window.event is the event property. For example window.event.type will give you the type of the event that took place. Like wise window.event.srcElement or window.event.target both properties return the HTML element the event took place on. window.event.srcElement.id is going to return the id of the event.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I've got part of code from friend and I'm trying to understand it and
I'm trying to understand the reasoning behind part of the CSS W3C spec: Why
Trying to understand Ruby a bit better, I ran into this code surfing the
Trying to understand the math of this code snippet. A token is provided which
I am now trying to understand how JPEG encoding works and everything seems fine
I'm trying to understand the code here , specifically the anonymous class private Runnable
Revising code of jQuery.reveal plugin (http://www.zurb.com/playground/reveal-modal-plugin) and trying to understand how it handles the
Trying to understand regular expressions and I am on the repetitions part: {m, n}
I'm trying to understand better how does const-correctness work and more specifically, when dealing
This is a function taken from Pro JavaScript techniques that I'm trying to understand,

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.