simple mailto function that composing an email from html file - javascript

I need to create a simple mailto function so when I click on the html file it brings up my default email application with the composed mail "ready-to-go." I figured a click event on the mailto ID would be sufficient, but it is not firing. What should I do? FYI, I do not want the user to click on the hyperlink. I plan on removing it.
<script type="text/javascript">
$(document).ready(function(){
$("#mymailto").click();
}); // document.ready
</script>
<!DOCTYPE HTML>
<HTML>
<HEAD>
<TITLE>Your Title Here</TITLE>
<META http-equiv="X-UA-Compatible" content="IE=edge">
<META http-equiv='cache-control' content='no-cache'>
<META http-equiv='expires' content='0'>
<META http-equiv='pragma' content='no-cache'>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>
</HEAD>
<BODY>
<a href="mailto:testEmail#gmail.com" id="mymailto" >email</a>
</BODY>
</HTML>

Just use document.location.href="mailto:testEmail#gmail.com";.

Related

Atom Editor Customize Default Autocomplete

I am a web developer and using Atom as text editor but I always have to change some autocomplete suggestions.
For example when I type html and pres tab it gives me this
<!DOCTYPE html>
<html lang="en" dir="ltr">
<head>
<meta charset="utf-8">
<title></title>
</head>
<body>
</body>
</html>
This result is not actually what so I manually change it like this
<!DOCTYPE html>
<html lang="en" dir="ltr">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<meta http-equiv="X-UA-Compatible" content="IE=11">
<meta name="author" content="Your name">
<meta name="description" content="Brief description">
<link rel="manifest" href="/manifest.json">
<link rel="icon" type="image/svg+xml" href="/favicon.svg">
<meta name="theme-color" content="#00FFF0">
<link href="style.css" rel="stylesheet">
<title>Title</title>
</head>
<body>
<script src="script.js"></script>
</body>
</html>
So I did a research and everybody solves this kind of similar issues with snippets I am not asking how can I do it with snippet. I already know it. I want to change these codes from editor's current location. Possibly it locates somewhere in ~/AppData/Local/atom but I haven't found it yet. I want to reach that file and change related suggestions from there.
This is not only for html suggestion I also want to remove something from PHP suggestion and add some for JavaScript suggestion.
Any idea how this system works and how to do it ?
Thanks.

why does not onload() work when i close the tab?

i wrote this simple function to show a message when you close the window but it didnt work.
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
</head>
<body onunload="closing()">
<script language="javascript">
function closing(){
alert('Bye');
}
</script>
</body>
</html>
Your popup blocker might block it. MDN docs source
That sort of behavior - alerts popping up on a close, are usually not desired by users.
Did you try using the unload event?

How to map different url to same page (HTML) Javascript?

What I am trying to do is when the user creates some post(social media post) it has a unique id in backend
example 1123 and one more post with unique id of 1134 there is only one html page How and to access them the urls are like this
mysite.com/post/1123------>post.html
mysite.com/post/1134------>post.html
how do I map these two urls to same page using javascript.
And I dont want to pass the unique ids in parameters because these are the links to specific post that all users can see
Can anybody help me on this
It should be like this
First Post with ID 1123
URL mysite.com/post/1123
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
</head>
<body>
<h1>hello id 1123</h1>
</body>
</html>
and the next post(social media post) with id 1134
URL mysite.com/post/1134
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
</head>
<body>
<h1>hello id 1134</h1>
</body>
</html>
And these two URL's are pointing to same html

Including js file in html properly with functions [duplicate]

This question already has answers here:
JavaScript not working on external file
(4 answers)
Closed 5 years ago.
i have 2 files....one html and one js....
html code:
<!DOCTYPE html
<html lang="en">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<script type="text/javascript" src="external.js"></script>
<title> Sign In And Registration Page </title>
</head>
<body>
<div id="headerTag">
</div>
///codes here....
</body>
</html>
js code:
some functions here performed on click operation.....
function onClickOperation ()
{
///here codes..
}
problem is that the functions are not being called...when i put the same js code in the html file directly, it works....what do i have to do to load those functions from separate js file?
external.js should have the code called after DOM has finished loading like so
document.addEventListener('DOMContentLoaded',function(){
// code here
});
or it should be included inside the body tag below the DOM elements it should interact with
Try wrapping the script in the body and just before the </body> tag:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title> Sign In And Registration Page </title>
</head>
<body>
<div id="headerTag">
</div>
///codes here....
<script type="text/javascript" src="external.js"></script>
</body>
</html>

getElementById Javascript not working?

I'm just kind of learning Javascript was following this exercise but it's not working and I don't understand. The page should read Some more text when loaded. But it's only show Some text from the paragraph. It not changing over with the getElementById like it should. Any tips?
<!doctype html>
<html>
<head>
<title>Learning Javascript</title>
<meta charset="utf-8" />
<meta http-equiv="Content-type" content="text/html; charset=utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
</head>
<body>
<p id="text">Some text</p>
<script type="text/javascript">
// This is a comment
/* Multi line comment
*/
document.getElementById{"text"}.innerHTML="Some more text";
</script>
</body>
</html>
document.getElementById("text").innerHTML="Some more text";
You have the wrong type of brackets. Use ()
You're using curly braces where you should be using parentheses.
Try this:
document.getElementById("text").innerHTML="Some more text";

Categories

Resources