This script is written in JavaScript and it’s used to remove the ?m=1 parameter from the URL if it’s present. Here's a breakdown of the code and how to place it correctly

 

This script is written in JavaScript and it’s used to remove the ?m=1 parameter from the URL if it’s present. Here's a breakdown of the code and how to place it correctly


INSTRUCTION VIDEO


Removing ?m=1 from Blogger URLs:

Changes Expected

  1. Mobile View: ?m=1 enables mobile view on Blogger. Removing it will display the desktop version.
  2. Speed Improvement: Removing ?m=1 enhances Blogger's load speed since unnecessary mobile view code isn't executed.
  3. SEO Impact: Removal positively impacts SEO as search engines won't index duplicate pages.
  4. Blogger Design: Layout changes may occur since ?m=1 controls mobile rendering.

Considerations

  • Ensure your Blogger template supports responsive design for seamless mobile and desktop transitions.
  • Test website functionality post-removal.
  • Customize your template's mobile view settings if needed.

To implement these changes, update your Blogger template code or utilize plugins/tools designed for this purpose.

Explanation of the Code

1. var uri = window.location.toString();

   - This line captures the current URL and stores it in a variable called uri.

2. if (uri.indexOf("?m=1") > 0)

   - This checks if ?m=1 exists in the URL. indexOf("?m=1") returns the position of ?m=1 if found; otherwise, it returns -1. So, > 0 means it’s checking that ?m=1 is present.

3. var clean_uri = uri.substring(0, uri.indexOf("?m=1"));

   - If ?m=1 is found, this line removes it from the URL by creating a substring that ends before ?m=1.

4. window.history.replaceState({}, document.title, clean_uri);

   - This replaces the current URL with the cleaned version, removing the ?m=1 without reloading the page.

 Full JavaScript Code (without CDATA)

You can write it directly as follows:

javascript

var uri = window.location.toString();

if (uri.indexOf("?m=1") > 0) {

    var clean_uri = uri.substring(0, uri.indexOf("?m=1"));

    window.history.replaceState({}, document.title, clean_uri);

}

 Where to Place It

1. In HTML <head>: Place it inside the <head> section of your HTML file, ideally in a <script> tag before other scripts to ensure it runs as the page loads. Example:

    html

    <head>

        <script>

            var uri = window.location.toString();

            if (uri.indexOf("?m=1") > 0) {

                var clean_uri = uri.substring(0, uri.indexOf("?m=1"));

                window.history.replaceState({}, document.title, clean_uri);

            }

        </script>

    </head>

2. Or Before Other Scripts in Body: You can also place it in the <body> section, as long as it’s before any other scripts that may rely on the URL.

3. In an External JavaScript File: You can add it to an external .js file, such as cleanURL.js, and include it in your HTML:

    html

    <head>

        <script src="cleanURL.js"></script>

    </head>

 Notes

- No CDATA Needed: The <![CDATA[]]> is generally used for XML documents; modern HTML5 doesn’t require it.

- Ensure Compatibility: This code requires JavaScript to be enabled on the browser for it to function properly.

Digital writer Suresh
      
<script>/*<![CDATA[*/ var uri = window.location.toString();if (uri.indexOf("?m=1","?m=1") > 0) {var clean_uri = uri.substring(0, uri.indexOf("?m=1"));window.history.replaceState({}, document.title, clean_uri); }; /*]]>*/</script>
    

Sponsored content:

"This Content Sponsored by Genreviews.Online

Genreviews.online is One of the Review Portal Site

Website Link: https://genreviews.online/

Sponsor Content: #genreviews.online, #genreviews, #productreviews, #bestreviews, #reviewportal"


Tags:

#BloggerSEO, #URLParameterRemoval, #JavaScript, #HTML, #BloggerTemplateCustomization, #URLCleaning, #BrowserHistoryManipulation, #ClientSideScripting, #BloggerTemplateEditing, #CustomBloggerTemplates, #BloggerSEOTweaks, #TemplateModification, #BloggerJavaScriptIntegration, #HTMLCoding,#BloggerDashboardCustomization



Post a Comment

Previous Post Next Post