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 7732301
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T06:41:51+00:00 2026-06-01T06:41:51+00:00

can someone explain to me why you can’t pass strings containing whitespace as parameters

  • 0

can someone explain to me why you can’t pass strings containing whitespace as parameters into javascript functions?

here’s my code which shows this issue, just hover over the link and you’ll see that only “mario” is shown as the title and not “mario and luigi”

 var href='mario and luigi', subject=$('div').data('subject'), 
 size=$('div').data('reviewid'), 
      src=$('div').data('itemid'), className='mini';

      function formatLink(href, subject, src, size, className){            
                if(size=='mini')
                size='height:25px; width:25px;';
                else if(size=='medium')
                size='height:40px; width:40px;';
                else if(size=='large')
                size='height:125px; width:125px;';
                else if(size=='xlarge')
                size='height:180px; width:260px;';                
            return '<a class="pjax" href='+href+' title='+subject+'><span class='+className+'><span class="image-wrap" style="position:relative; display:inline-block; background:url('+src+') no-repeat center center;'+size+'" ><img style="opacity:0;"></span></span><span title='+subject+'>'+subject+'</span></a>';
        }
var link=formatLink(href, subject, src, size, className);
$('div').html(link);
​
  • 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-01T06:41:52+00:00Added an answer on June 1, 2026 at 6:41 am

    title='+subject+' should be title="'+subject+'". You need to quote the attribute, otherwise the markup is invalid.

    As a bonus, here’s an analog of python’s format function which makes things like this much easier:

    format = function(str, params) {
        return str.replace(/\{(\w+)\}/g, function($0, $1) { return params[$1] });
    }
    

    Usage:

    html = format(
        '<a class="pjax" href="{href}" title="{subject}"><span class="{className}"... etc',
        {
            href: "some_link",
            subject: "mario and luigi",
            className: "foobar"
        }
    )
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

can someone explain why the compiler accepts only this code template<typename L, size_t offset,
Can someone explain me the rationale behind having these two functions, instead of just
Can someone explain which indexed search would be faster, listing from fastest, to slowest
Can someone explain and give example code to do the following steps in my
Can someone explain to me why this code fails once in a while with
Can someone explain what this ajax code does? function ajaxProgress(){ //Math.random() is for bitchy
Can someone explain to me why this code prints 14? I was just asked
Can someone explain to or link to an article that explains how the parameters
Can someone explain to me why my code: string messageBody = abc\n + stringFromDatabaseProcedure;
Can someone explain in English what is going on here? std::vector<Cat*> cats; //I get

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.