Italics Not Working In Javascript 'alert()' Method? - javascript

I have been using jsFiddle to run Javascript, and am not currently using a library (i.e., jQuery). I would like to use italics in an alert box, but whenever I do it prints the
<em>Example</em>
tags. If I use
str.italics()
method it prints
<i>Example</i>
Why doesn't it work, and is there any way around this?

You can't inject HTML in an alert. I would recommend avoiding using alerts for anything other than testing. Creating a custom alert dialog box / lightbox is not hard, and looks much nicer.

Related

How do I write OnMouseOut so it closes a popup tooltip?

I have this code creating a popup/tooltip when specific text is hovered by the user:
function popup() {
$('#example').load("example.html");
}
I add this to make the tooltip appear:
<div id="example" onmouseover="popup(this)" onmouseout="popup.close();">Hover over this!</div>
What that's doing, I'm happy I succeeded figuring out, is when the user hovers over the text "Hover over this!" a window appears and displays example.html as the content of the popup window. I included onmouseout="popup.close();" in an attempt to get it to automatically close.
I'm trying to get it to also close the popup when the user moves their mouse away from the text. I've tried this:
function popup() {
$('#example').load("example.html");
}
function close(){
popup(this).close();
}
Which, obviously to those who know more than me, didn't cause the window to close.
How do I have to write a very simple version of this code correctly so it closes the popup onMouseOut?
I've found this solution that's very similar but I'm not 100% sure how to edit that either to get it loading the external page I want.
Edit: Nope. The solution in the above link didn't work out for me.
I'm not super skilled in JS, so bear with me. It looks like you have a function to display the popup, so I will assume that is working well. I only have a few suggestions, my best one is to have an if/else statement.
If the mouse cursor is over the text, display the popup.
Else, hide the popup.
I don't see a reason why the functions you set up wouldn't be working, so you should just be able to add that. For fear of giving incorrect advice, I will not be showing code because I suck at JS and it will probably be incorrect. But do some research and see if that works. Some other people might have better feedback than me.
First, you have to know the basics of JS.
jQuery is its library/framework, written by an enthusiastic programmers like you. At first, JavaScript.
<div onmouseover="this.innerText='7'"
onmouseout="this.innerText='77'">Hover please!</div>
On mousing over it, the text is 7, on mouse out it is 77 .
This is basic.
And the language is not Java.
JavaScript is easier a little bit.
This is what you got to know now.
The first thing here you have to know is HTML on the web.
Then you get to JavaScript (basically without jQuery at first ).
You were using the jQuery library ajax methods of JavaScript .
<!--normal code (it's a comment!)-->
<script>function getLoad(){return '<iframe src="example.html"/>' }</script>
(return means give out value).
<div onmouseover="this.innerHTML=getLoad()" onmouseout="this.innerHTML='Hover please!'">Hover please!
</div>

Image In JavaScript Alert

I know it's a unwise question but if it's possible -
Can we show a image in JavaScript alert box?
If it's possible, How can we do this?
No. You cannot display an image inside JavaScript's native alert() box.
Side note: alert() displays what's given to it as input as pure text, meaning you cannot pass a string containing an <img> tag to it and expect it to display an image - it will instead display the string "<img src...>".
no it's not possible but why not make something that looks like it. for example a popup.
JS alert box has no place to place image, but you can create your own alert style, as you wish, e.g. show a DIV at screen center with background dimmed (just like Facebook, and many other sites)
Its not possible using the normal alert function, you may consider trying this using the jQuery Dialog to simulate the alertbox
No, you can't display image with js alert box, but you can wit jquery. Maybe this plugin would be interesting for you:
WowWindow plugin
It's not possible with vanilla JavaScript, although you could use the <div> element, Bootstrap modals, or JavaScript libraries.
Bootstrap example: https://www.w3schools.com/bootstrap/bootstrap_modal.asp
It's not possible, but you can show the img in a modal.

Can The Preview Pane in the MarkdownDeep Markdown Editor be Disabled?

I'm working on an ASP.NET MVC project which uses the MarkdownDeep Editor to add a rich editor on top of a basic markdown input textbox (very similar to the Stackoverflow editor window).
Generally it works great. However, in certain scenarios, I would like to disable the preview window. This is automatically generated below the textarea by MDD. Can this be disabled?
Just to be clear, I know I can use CSS to hide the preview. But on some devices it's slow and makes typing painful. I want to entirely turn off that feature. I don't see anything in the docs other than how to customize the preview.
Any ideas?
In the docs it specifically mentions that it is recommended that you have the div preview already in your document because it will be created if it isn't found and consequently, could could a visible page refresh if any re-layout has to occur.
Note: the associated divs are all optional and if missing, the plugin will create them. However... you might experience the page jumping around during load if you do this. ie: it's recommended to explicitly include them.
Thus from the sounds of this, and that there doesn't appear to be any option to turn it off in the API page I would say no, it's not possible.
I am a little confused here: if you don't want the preview, use a regular text area instead of mdd_editor... So, under the scenarios where you don't need the previews, instantiate a plain vanilla editor. What am I missing here?
I know this is old, but I was looking for something else on mdd. I recently had this same requirement.
Just comment out the code
// Update the DOM
if (this.m_divHtml)
this.m_divHtml.innerHTML=output;
in MarkdownDeepEditor.js

Show hyperlinks in javascript alert

Is it possible to show hyperlinks in javascript alerts?
I mean, if I do something like
alert("<a href='http://stackoverflow.com'>LINK</a>");
the alert will show only the plain text "LINK".
Is it possibile to show it like a clickable url?
Thanks
It is possible if you make your own web browser, which you won't do, becauseā€¦ well, just because. Otherwise, it's impossible (still).
However, alert has always sucked, so a modal dialog may be better.
Not possible. Use "custom" alert dialog, you have plenty jQuery plugins for this.

javascript live text highlighter like diigo.com

Does anyone know how to make a live text highlighter in javascript/jquery? with most script ive seen, you have to select the text first then click highlight. how does diigo.com do it?
Simple javascript can not provide functionality like diigo.com.
You need to write browser plugins.
This type of plugins are called BHO (Browser Helper Object)
Creating BHO need some experience and understanding of COM.
See the examples below
Exaple 1
Exaple 2
Example 3

Categories