Skip to content
geeksforgeeks
  • Courses
    • DSA to Development
    • Get IBM Certification
    • Newly Launched!
      • Master Django Framework
      • Become AWS Certified
    • For Working Professionals
      • Interview 101: DSA & System Design
      • Data Science Training Program
      • JAVA Backend Development (Live)
      • DevOps Engineering (LIVE)
      • Data Structures & Algorithms in Python
    • For Students
      • Placement Preparation Course
      • Data Science (Live)
      • Data Structure & Algorithm-Self Paced (C++/JAVA)
      • Master Competitive Programming (Live)
      • Full Stack Development with React & Node JS (Live)
    • Full Stack Development
    • Data Science Program
    • All Courses
  • Tutorials
    • Data Structures & Algorithms
    • ML & Data Science
    • Interview Corner
    • Programming Languages
    • Web Development
    • CS Subjects
    • DevOps And Linux
    • School Learning
  • Practice
    • GfG 160: Daily DSA
    • Problem of the Day
    • Practice Coding Problems
    • GfG SDE Sheet
  • JS Tutorial
  • JS Exercise
  • JS Interview Questions
  • JS Array
  • JS String
  • JS Object
  • JS Operator
  • JS Date
  • JS Error
  • JS Projects
  • JS Set
  • JS Map
  • JS RegExp
  • JS Math
  • JS Number
  • JS Boolean
  • JS Examples
  • JS Free JS Course
  • JS A to Z Guide
  • JS Formatter
Open In App
Next Article:
How to Create a Binary Calculator using HTML, CSS and JavaScript ?
Next article icon

Create Aspect Ratio Calculator using HTML CSS and JavaScript

Last Updated : 23 Jul, 2024
Comments
Improve
Suggest changes
Like Article
Like
Report

In this article, we are going to implement an aspect ratio calculator. An aspect ratio calculator proves to be a useful tool for individuals seeking to determine the proportions of images or videos based on their width and height. Our aspect ratio calculator has a live preview option that enables users to visualize how adjustments in width and height impact the image's aspect ratio.

Create-a-Aspect-Ratio-Calculator-Using-HTML-CSS-and-JavaScript

Prerequisites

  • HTML
  • CSS
  • JavaScript

Approach

  • The HTML file comprises input fields for width and height, allowing users to define the desired dimensions. Additionally, it includes a drop-down menu offering commonly used aspect ratios and designated areas to display the results.
  • CSS styles enhance the visual appeal of the calculator, providing it with a clean and responsive design adorned by a subtle color scheme. The centered container adds to its aesthetic charm, while the input styling contributes to a seamless user experience. Additionally, users can enjoy a visually captivating image preview feature.
  • JavaScript takes care of handling input changes, performing calculations for different aspect ratios (diagonal, x:1 format, and w:h format), and dynamically updating the image preview. To enhance user-friendliness, the "Se­t Common Ratio" function automatically fills in inputs with frequently used aspe­ct ratios.

Example

HTML
<!--Index.html-->
<!DOCTYPE html>
<html>

<head>
	<title>
		Aspect Ratio Calculator 
		with Live Image Preview
	</title>
	<link rel="stylesheet" href="style.css">
</head>

<body>
	<div class="container">
		<h1>Aspect Ratio Calculator with 
		<span>Live Preview </span> 
		</h1>

		<label for="width">Width:</label>
		<input type="number"
			id="width"
			placeholder="Enter width"
			oninput="calculateAspectRatio()">
		<br>

		<label for="height">Height:</label>
		<input type="number"
			id="height"
			placeholder="Enter height"
			oninput="calculateAspectRatio()">
		<br>

		<label for="commonRatios">Select Common Ratio:</label>
		<select id="commonRatios" onchange="setCommonRatio()">
			<option value="16:9">
				16:9 (1920x1080)
			</option>
			<option value="5:4">
				5:4 (1280x1024)
			</option>
			<option value="4:3">
				4:3 (1024x768)
			</option>
			<option value="3:2">
				3:2 (1440x960)
			</option>
			<option value="8K">
				8K (7680x4320)
			</option>
			<option value="5K">
				5K (5120x2880)
			</option>
			<option value="4K">
				4K (3840x2160)
			</option>
			<option value="Retina">
				IPad with Retina (2048x1536)
			</option>
			<option value="iPhone6plus">
				IPhone 6 Plus (1920x1080)
			</option>
			<option value="iPhone6">
				IPhone 6 (1334x750)
			</option>
			<option value="iPhone5">
				IPhone 5 (1136x640)
			</option>
			<option value="iPad">
				IPad (1024x768)
			</option>
			<option value="Twitter">
				Twitter (1024x512)
			</option>
			<option value="WebBanner">
				Common Web Banner (728x90)
			</option>
			<option value="VGA">
				VGA (640x480)
			</option>
			<option value="HVGA">
				HVGA (320x480)
			</option>
		</select>
		<br>

		<button onclick="calculateAspect()">Calculate</button>

		<p class="result" id="result1">
			Diagonal: 
		</p>
		<p class="result" id="result2">
			Aspect Ratio (x:1 format): 
		</p>
		<p class="result" id="result3">
			Aspect Ratio (w:h format): 
		</p>

		<div id="imageContainer">
			<img id="previewImage"
				src=
"https://media.geeksforgeeks.org/wp-content/uploads/20230816223829/geeksgforgeeks-logo-1.png"
				alt="Preview Image">
		</div>
	</div>

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

</html>
CSS
/*Style.css*/
body {
	font-family: Arial, sans-serif;
	background-color: #f5f5f5;
	text-align: center;
}
.container {
	max-width: 700px;
	margin: 20px auto;
	background-color: #ffffff;
	padding: 40px;
	border-radius: 15px;
	box-shadow: 0 2px 14px 0px
		rgba(0, 0, 0, 0.1);
}
h1 {
	font-size: 24px;
	margin-bottom: 20px;
}
span {
	color: #007bff;
}
label {
	display: block;
	font-weight: bold;
	margin-top: 10px;
}
input,
select {
	width: 90%;
	padding: 10px;
	margin-top: 5px;
	border: 1px solid #ccc;
	border-radius: 5px;
	font-size: 16px;
}
select {
	height: 50px;
}
button {
	width: 20%;
	background-color: #007bff;
	color: #fff;
	padding: 10px;
	border: none;
	border-radius: 5px;
	font-size: 16px;
	margin-top: 20px;
	cursor: pointer;
}
button:hover {
	background-color: #0056b3;
}
.result {
	font-weight: bold;
	margin-top: 20px;
}
.image-container {
	background-color: white;
	display: inline-block;
	max-width: 100%;
	margin-top: 20px;
}
img {
	max-width: 100%;
	height: auto;
	border-radius: 10px;
	box-shadow: 0 2px 24px 0px grey;
}
JavaScript
// Script.js
const calculateAspectRatio = () => {
	const widthInput =
		document.getElementById("width");
	const heightInput =
		document.getElementById("height");
	const width = parseFloat(widthInput.value);
	const height = parseFloat(heightInput.value);

	if (!isNaN(width) &&
		!isNaN(height)) {
		const diagonal = Math.sqrt(
			width ** 2 + height ** 2
		).toFixed(2);
		document.getElementById("result1")
			.textContent = "Diagonal = " + diagonal;

		const x = (
			width / height
		).toFixed(2);
		document.getElementById(
			"result2"
		).textContent =
			"Aspect Ratio (x:1 format) = " +
			x +
			" : 1";

		const gcd = (a, b) => {
			while (b) {
				a %= b;
				[a, b] = [b, a];
			}
			return a;
		};

		const gcdValue = gcd(
			width,
			height);
		const w = width / gcdValue;
		const h = height / gcdValue;
		document.getElementById(
			"result3"
		).textContent =
			"Aspect Ratio (w:h format) = " +
			w +
			" : " +
			h;

		// Apply aspect ratio to the preview image
		const imageElement =
			document.getElementById(
				"previewImage"
			);
		imageElement.style.width = `${width}px`;
		imageElement.style.height = `${height}px`;
	}
	else {

		// Clear results and reset image on invalid input
		document.getElementById(
			"result1"
		).textContent = "Diagonal: ";
		document.getElementById(
			"result2"
		).textContent =
			"Aspect Ratio (x:1 format): ";
		document.getElementById(
			"result3"
		).textContent =
			"Aspect Ratio (w:h format): ";

		const imageElement =
			document.getElementById(
				"previewImage"
			);
		imageElement.style.width =
			"auto";
		imageElement.style.height =
			"auto";
	}
}

const setCommonRati = () => {
	const commonRatios = {
		"16:9": [1920, 1080],
		"5:4": [1280, 1024],
		"4:3": [1024, 768],
		"3:2": [1440, 960],
		"8K": [7680, 4320],
		"5K": [5120, 2880],
		"4K": [3840, 2160],
		Retina: [2048, 1536],
		iPhone6plus: [1920, 1080],
		iPhone6: [1334, 750],
		iPhone5: [1136, 640],
		iPad: [1024, 768],
		Twitter: [1024, 512],
		WebBanner: [728, 90],
		VGA: [640, 480],
		HVGA: [320, 480],
	};
	const selectedRatio =
		document.getElementById(
			"commonRatios"
		).value;
	const [width, height] =
		commonRatios[selectedRatio];
	document.getElementById(
		"width"
	).value = width;
	document.getElementById(
		"height"
	).value = height;

	// Update the results and preview 
	// for the selected common ratio
	calculateAspectRatio();
}

// Initialize the image aspect ratio 
// based on the placeholder image
calculateAspectRatio();

Output


Next Article
How to Create a Binary Calculator using HTML, CSS and JavaScript ?
author
saurabhkumarsharma05
Improve
Article Tags :
  • JavaScript
  • Web Technologies
  • Geeks Premier League
  • JavaScript-Projects
  • Geeks Premier League 2023

Similar Reads

    HTML Calculator
    HTML calculator is used for performing basic mathematical operations like Addition, subtraction, multiplication, and division.You can find the live preview below, try it: To design the basic calculator, we will use HTML , CSS , and JavaScript . HTML is used to design the basic structure of the calcu
    3 min read
    JavaScript Calculator
    To build a simple calculator using JavaScript, we need to handle basic arithmetic operations such as addition, subtraction, multiplication, and division. JavaScript, along with HTML and CSS, is commonly used to create interactive web-based calculators.What We Are Going to CreateWe will build a simpl
    7 min read
    JavaScript Scientific Calculator
    The HTML Scientific Calculator is a tool for performing advanced scientific calculations like finding exponents, logarithms, factorials, and more. This calculator comprises two sections: the input section, where the user types in their mathematical problem, and the output screen, which displays all
    4 min read
    JavaScript Neumorphism Effect Calculator
    In this article, we will learn how to create a working calculator with the Neumorphism effect using HTML, CSS, and JavaScript. Basic mathematical operations such as addition, subtraction, multiplication, and division can be performed using this calculator. Approach: Neumorphism is a contemporary app
    3 min read
    JavaScript Age Calculator
    In the Age Calculator, the user enters their date of birth using a date input field. The tool calculates and displays the exact age in years, months, and days from the current date (or a specified date). We'll design the layout using HTML and CSS, and add functionality using JavaScript. It will also
    3 min read
    JavaScript Tip Calculator
    The tip is the money given as a gift for good service to the person who serves you in a restaurant. In this project, a simple tip calculator is made that takes the billing amount, type of service, and the number of persons as input. As per the three inputs, it generates a tip for the serving person.
    4 min read
    JavaScript Geometry Calculator
    In this article, we will see how to design a Geometry Calculator using HTML, CSS, and JavaScript. A Geometry calculator is used to calculate the area and parameters of different shapes and figures, like circles, rectangles, squares, triangles, etc. This can be helpful in cases where one wants to cal
    4 min read
    JavaScript Aspect Ratio Calculator
    In this article, we are going to implement an aspect ratio calculator. An aspect ratio calculator proves to be a useful tool for individuals seeking to determine the proportions of images or videos based on their width and height. Our aspect ratio calculator has a live preview option that enables us
    5 min read
    JavaScript Binary Calculator
    HTML or HyperText Markup Language along with CSS (Cascading Stylesheet) and JavaScript can be used to develop interactive user applications that can perform certain functionalities. Similarly, a binary calculator can be developed using HTML, CSS, and JS altogether. Binary Calculator performs arithme
    5 min read
    JavaScript Percentage Calculator
    The percentage calculator is useful for students, shopkeepers, and for solving basic mathematical problems related to percentages. In this article, we are going to learn, how to make a percentage calculator using HTML CSS, and JavaScriptFormula used:What is X percent of Y is given by the formula: X
    3 min read
    JavaScript Profit and Loss Calculator
    In this article, we will create a profit & loss calculator using HTML, CSS & Javascript for adding the basic functionality along with adding the design and layout. Profit and Loss Calculator is basically used to calculate the amount or percentage received after selling a particular price or
    3 min read
    JavaScript BMI Calculator
    A BMI (Body Mass Index) Calculator measures body fat based on weight and height, providing a numerical value to categorize individuals as underweight, normal weight, overweight, or obese. It’s widely used to assess health risks and guide lifestyle or medical decisions.A BMI Calculator using JavaScri
    3 min read
    JavaScript Temperature Calculator
    In this article, we will see Temperature Conversion between Celsius, Fahrenheit & Kelvin using HTML CSS & JavaScript. The Temperature is generally measured in terms of unit degree., i.e. in degrees centigrade, in degrees, Fahrenheit & Kelvin. Celsius is a standard unit of temperature on
    3 min read
    JavaScript Student Grade Calculator
    A Student Grade Calculator is a tool used to compute students' grades based on their scores in various assessments, such as assignments, quizzes, exams, or projects. It helps standardize grading, ensures accuracy, and provides students with a clear understanding of their academic performance.Formula
    4 min read
    JavaScript Loan Calculator
    The Loan Calculator can be used to calculate the monthly EMI of the loan by taking the total amount, months to repay, and the rate of interest.Formula Used:interest = (amount * (rate * 0.01))/months;total = ((amount/months) + interest);ApproachExtract values from HTML input elements (#amount, #rate,
    2 min read
    JavaScript Interest Calculator
    Simple Interest is the term used to describe the rate at which money is borrowed or lent. Simple Interest Calculator serves as a practical tool for computing interest on loans or savings without compounding. It allows you to determine the simple interest on the principal amount, offering flexibility
    3 min read
    JavaScript CGPA Calculator
    Nowadays, colleges use grades like A, B, C, D, and F, and assign credits to courses. In this calculator, you just need to input your subject name, grade, and credit. We'll also include options to update or delete information in case of mistakes. This way, you won't have to re-enter all details if yo
    4 min read
    JavaScript Bartletts Test Calculator
    In this article, we are going to implement Bartlett's test calculator in JavaScript. Bartlett's test is a statistical test used to determine whether the variances of multiple groups are homogeneous and plays a crucial role in various fields of experimental research such as analysis of variance and h
    3 min read
    JavaScript Unit Converter
    In this article, we will be developing an interactive and styled unit converter using HTML, CSS, and JavaScript.In this application, we have a select category option box in which different types of units are specified, like temperature, area, weight, length, and time. As per the user selection, the
    7 min read
    JavaScript Length Converter
    In this article, we will learn how to create a length converter using HTML, CSS, and JavaScript. The Length Converter is an intuitive web-based application that eliminates the complexities associated with manual conversions. Its user-friendly interface allows users to input a numerical value and sel
    6 min read
geeksforgeeks-footer-logo
Corporate & Communications Address:
A-143, 7th Floor, Sovereign Corporate Tower, Sector- 136, Noida, Uttar Pradesh (201305)
Registered Address:
K 061, Tower K, Gulshan Vivante Apartment, Sector 137, Noida, Gautam Buddh Nagar, Uttar Pradesh, 201305
GFG App on Play Store GFG App on App Store
Advertise with us
  • Company
  • About Us
  • Legal
  • Privacy Policy
  • In Media
  • Contact Us
  • Advertise with us
  • GFG Corporate Solution
  • Placement Training Program
  • Languages
  • Python
  • Java
  • C++
  • PHP
  • GoLang
  • SQL
  • R Language
  • Android Tutorial
  • Tutorials Archive
  • DSA
  • Data Structures
  • Algorithms
  • DSA for Beginners
  • Basic DSA Problems
  • DSA Roadmap
  • Top 100 DSA Interview Problems
  • DSA Roadmap by Sandeep Jain
  • All Cheat Sheets
  • Data Science & ML
  • Data Science With Python
  • Data Science For Beginner
  • Machine Learning
  • ML Maths
  • Data Visualisation
  • Pandas
  • NumPy
  • NLP
  • Deep Learning
  • Web Technologies
  • HTML
  • CSS
  • JavaScript
  • TypeScript
  • ReactJS
  • NextJS
  • Bootstrap
  • Web Design
  • Python Tutorial
  • Python Programming Examples
  • Python Projects
  • Python Tkinter
  • Python Web Scraping
  • OpenCV Tutorial
  • Python Interview Question
  • Django
  • Computer Science
  • Operating Systems
  • Computer Network
  • Database Management System
  • Software Engineering
  • Digital Logic Design
  • Engineering Maths
  • Software Development
  • Software Testing
  • DevOps
  • Git
  • Linux
  • AWS
  • Docker
  • Kubernetes
  • Azure
  • GCP
  • DevOps Roadmap
  • System Design
  • High Level Design
  • Low Level Design
  • UML Diagrams
  • Interview Guide
  • Design Patterns
  • OOAD
  • System Design Bootcamp
  • Interview Questions
  • Inteview Preparation
  • Competitive Programming
  • Top DS or Algo for CP
  • Company-Wise Recruitment Process
  • Company-Wise Preparation
  • Aptitude Preparation
  • Puzzles
  • School Subjects
  • Mathematics
  • Physics
  • Chemistry
  • Biology
  • Social Science
  • English Grammar
  • Commerce
  • World GK
  • GeeksforGeeks Videos
  • DSA
  • Python
  • Java
  • C++
  • Web Development
  • Data Science
  • CS Subjects
@GeeksforGeeks, Sanchhaya Education Private Limited, All rights reserved
We use cookies to ensure you have the best browsing experience on our website. By using our site, you acknowledge that you have read and understood our Cookie Policy & Privacy Policy
Lightbox
Improvement
Suggest Changes
Help us improve. Share your suggestions to enhance the article. Contribute your expertise and make a difference in the GeeksforGeeks portal.
geeksforgeeks-suggest-icon
Create Improvement
Enhance the article with your expertise. Contribute to the GeeksforGeeks community and help create better learning resources for all.
geeksforgeeks-improvement-icon
Suggest Changes
min 4 words, max Words Limit:1000

Thank You!

Your suggestions are valuable to us.

'); // $('.spinner-loading-overlay').show(); let script = document.createElement('script'); script.src = 'https://assets.geeksforgeeks.org/v2/editor-prod/static/js/bundle.min.js'; script.defer = true document.head.appendChild(script); script.onload = function() { suggestionModalEditor() //to add editor in suggestion modal if(loginData && loginData.premiumConsent){ personalNoteEditor() //to load editor in personal note } } script.onerror = function() { if($('.editorError').length){ $('.editorError').remove(); } var messageDiv = $('
').text('Editor not loaded due to some issues'); $('#suggestion-section-textarea').append(messageDiv); $('.suggest-bottom-btn').hide(); $('.suggestion-section').hide(); editorLoaded = false; } }); //suggestion modal editor function suggestionModalEditor(){ // editor params const params = { data: undefined, plugins: ["BOLD", "ITALIC", "UNDERLINE", "PREBLOCK"], } // loading editor try { suggestEditorInstance = new GFGEditorWrapper("suggestion-section-textarea", params, { appNode: true }) suggestEditorInstance._createEditor("") $('.spinner-loading-overlay:eq(0)').remove(); editorLoaded = true; } catch (error) { $('.spinner-loading-overlay:eq(0)').remove(); editorLoaded = false; } } //personal note editor function personalNoteEditor(){ // editor params const params = { data: undefined, plugins: ["UNDO", "REDO", "BOLD", "ITALIC", "NUMBERED_LIST", "BULLET_LIST", "TEXTALIGNMENTDROPDOWN"], placeholderText: "Description to be......", } // loading editor try { let notesEditorInstance = new GFGEditorWrapper("pn-editor", params, { appNode: true }) notesEditorInstance._createEditor(loginData&&loginData.user_personal_note?loginData.user_personal_note:"") $('.spinner-loading-overlay:eq(0)').remove(); editorLoaded = true; } catch (error) { $('.spinner-loading-overlay:eq(0)').remove(); editorLoaded = false; } } var lockedCasesHtml = `You can suggest the changes for now and it will be under 'My Suggestions' Tab on Write.

You will be notified via email once the article is available for improvement. Thank you for your valuable feedback!`; var badgesRequiredHtml = `It seems that you do not meet the eligibility criteria to create improvements for this article, as only users who have earned specific badges are permitted to do so.

However, you can still create improvements through the Pick for Improvement section.`; jQuery('.improve-header-sec-child').on('click', function(){ jQuery('.improve-modal--overlay').hide(); $('.improve-modal--suggestion').hide(); jQuery('#suggestion-modal-alert').hide(); }); $('.suggest-change_wrapper, .locked-status--impove-modal .improve-bottom-btn').on('click',function(){ // when suggest changes option is clicked $('.ContentEditable__root').text(""); $('.suggest-bottom-btn').html("Suggest changes"); $('.thank-you-message').css("display","none"); $('.improve-modal--improvement').hide(); $('.improve-modal--suggestion').show(); $('#suggestion-section-textarea').show(); jQuery('#suggestion-modal-alert').hide(); if(suggestEditorInstance !== null){ suggestEditorInstance.setEditorValue(""); } $('.suggestion-section').css('display', 'block'); jQuery('.suggest-bottom-btn').css("display","block"); }); $('.create-improvement_wrapper').on('click',function(){ // when create improvement option clicked then improvement reason will be shown if(loginData && loginData.isLoggedIn) { $('body').append('
'); $('.spinner-loading-overlay').show(); jQuery.ajax({ url: writeApiUrl + 'create-improvement-post/?v=1', type: "POST", contentType: 'application/json; charset=utf-8', dataType: 'json', xhrFields: { withCredentials: true }, data: JSON.stringify({ gfg_id: post_id }), success:function(result) { $('.spinner-loading-overlay:eq(0)').remove(); $('.improve-modal--overlay').hide(); $('.unlocked-status--improve-modal-content').css("display","none"); $('.create-improvement-redirection-to-write').attr('href',writeUrl + 'improve-post/' + `${result.id}` + '/', '_blank'); $('.create-improvement-redirection-to-write')[0].click(); }, error:function(e) { showErrorMessage(e.responseJSON,e.status) }, }); } else { if(loginData && !loginData.isLoggedIn) { $('.improve-modal--overlay').hide(); if ($('.header-main__wrapper').find('.header-main__signup.login-modal-btn').length) { $('.header-main__wrapper').find('.header-main__signup.login-modal-btn').click(); } return; } } }); $('.left-arrow-icon_wrapper').on('click',function(){ if($('.improve-modal--suggestion').is(":visible")) $('.improve-modal--suggestion').hide(); else{ } $('.improve-modal--improvement').show(); }); const showErrorMessage = (result,statusCode) => { if(!result) return; $('.spinner-loading-overlay:eq(0)').remove(); if(statusCode == 403) { $('.improve-modal--improve-content.error-message').html(result.message); jQuery('.improve-modal--overlay').show(); jQuery('.improve-modal--improvement').show(); $('.locked-status--impove-modal').css("display","block"); $('.unlocked-status--improve-modal-content').css("display","none"); $('.improve-modal--improvement').attr("status","locked"); return; } } function suggestionCall() { var editorValue = suggestEditorInstance.getValue(); var suggest_val = $(".ContentEditable__root").find("[data-lexical-text='true']").map(function() { return $(this).text().trim(); }).get().join(' '); suggest_val = suggest_val.replace(/\s+/g, ' ').trim(); var array_String= suggest_val.split(" ") //array of words var gCaptchaToken = $("#g-recaptcha-response-suggestion-form").val(); var error_msg = false; if(suggest_val != "" && array_String.length >=4){ if(editorValue.length { jQuery('.ContentEditable__root').focus(); jQuery('#suggestion-modal-alert').hide(); }, 3000); } } document.querySelector('.suggest-bottom-btn').addEventListener('click', function(){ jQuery('body').append('
'); jQuery('.spinner-loading-overlay').show(); if(loginData && loginData.isLoggedIn) { suggestionCall(); return; } // script for grecaptcha loaded in loginmodal.html and call function to set the token setGoogleRecaptcha(); }); $('.improvement-bottom-btn.create-improvement-btn').click(function() { //create improvement button is clicked $('body').append('
'); $('.spinner-loading-overlay').show(); // send this option via create-improvement-post api jQuery.ajax({ url: writeApiUrl + 'create-improvement-post/?v=1', type: "POST", contentType: 'application/json; charset=utf-8', dataType: 'json', xhrFields: { withCredentials: true }, data: JSON.stringify({ gfg_id: post_id }), success:function(result) { $('.spinner-loading-overlay:eq(0)').remove(); $('.improve-modal--overlay').hide(); $('.create-improvement-redirection-to-write').attr('href',writeUrl + 'improve-post/' + `${result.id}` + '/', '_blank'); $('.create-improvement-redirection-to-write')[0].click(); }, error:function(e) { showErrorMessage(e.responseJSON,e.status); }, }); });
"For an ad-free experience and exclusive features, subscribe to our Premium Plan!"
Continue without supporting
`; $('body').append(adBlockerModal); $('body').addClass('body-for-ad-blocker'); const modal = document.getElementById("adBlockerModal"); modal.style.display = "block"; } function handleAdBlockerClick(type){ if(type == 'disabled'){ window.location.reload(); } else if(type == 'info'){ document.getElementById("ad-blocker-div").style.display = "none"; document.getElementById("ad-blocker-info-div").style.display = "flex"; handleAdBlockerIconClick(0); } } var lastSelected= null; //Mapping of name and video URL with the index. const adBlockerVideoMap = [ ['Ad Block Plus','https://media.geeksforgeeks.org/auth-dashboard-uploads/abp-blocker-min.mp4'], ['Ad Block','https://media.geeksforgeeks.org/auth-dashboard-uploads/Ad-block-min.mp4'], ['uBlock Origin','https://media.geeksforgeeks.org/auth-dashboard-uploads/ub-blocke-min.mp4'], ['uBlock','https://media.geeksforgeeks.org/auth-dashboard-uploads/U-blocker-min.mp4'], ] function handleAdBlockerIconClick(currSelected){ const videocontainer = document.getElementById('ad-blocker-info-div-gif'); const videosource = document.getElementById('ad-blocker-info-div-gif-src'); if(lastSelected != null){ document.getElementById("ad-blocker-info-div-icons-"+lastSelected).style.backgroundColor = "white"; document.getElementById("ad-blocker-info-div-icons-"+lastSelected).style.borderColor = "#D6D6D6"; } document.getElementById("ad-blocker-info-div-icons-"+currSelected).style.backgroundColor = "#D9D9D9"; document.getElementById("ad-blocker-info-div-icons-"+currSelected).style.borderColor = "#848484"; document.getElementById('ad-blocker-info-div-name-span').innerHTML = adBlockerVideoMap[currSelected][0] videocontainer.pause(); videosource.setAttribute('src', adBlockerVideoMap[currSelected][1]); videocontainer.load(); videocontainer.play(); lastSelected = currSelected; }

What kind of Experience do you want to share?

Interview Experiences
Admission Experiences
Career Journeys
Work Experiences
Campus Experiences
Competitive Exam Experiences