Alert Box error - javascript

I have alert boxes all around my site, that have been working up until now, ( I have done a few updates to my blog recently before this started happening ) the problem I am experienceing is that when I click on a link ( in my case a image link ) and the alert box appears, I submitt the ok button and suddenly im rediercted to a white page with 'true' in the top corner. My alert box scripts are inside my blog template.
I tested this alert box script out in a blog post:
<"a href="javascript:onClick=alert("Not an active link");">CLICK<"/a>
withouth the extra "
and then went to preview the post, however the same error occured. This is not a browser problem as it only happens on my site, when i got to someone elses with alert boxes, it works. Please help with this I have been asking about it for about a week now and would appreciate someone who can help
here is a screenshot of what I get redirected to:
http://img813.imageshack.us/img813/2674/true.png
Thanks for all help.

Use this
CLICK
Demo here: http://jsfiddle.net/e2fkT/embedded/result/

I think you have some typos... It would be:
click
Use simple quotes inside or escape double quotes.
I don't understand the use of onclick there too... Just the alert will open an alert box when you click.
click
Also it would be better to separate javascript from html... You could include with the following content (jquery example, i forgot almost everything about old javascript... just get the idea) into a non-active-links.js file or in a block:
$(document).ready(function () {
$('a.non-active-link').click(function () {
window.alert('Not an active link');
return false;
});
});
That way all links in the page with a class attribute of "non-active-link" will fire up the alert box.

I think you messed up with javascript inside href and the onclick attribute. Your snippet is actually assigning the result of the alert function call to the variable onCLick. The display of true might be the return value of the alert method. Still an odd behavior.
CLICK
CLICK
Those two cause no problems to me.

Related

How can I make a function to program Chrome to set itself the "Break" status at my workplace

I am working in a call center, and everytime i go to the toilet, I have to change my status to "Break" using a dropdown menu from the google chrome page(internal website).
I can use inspect and see all the classes and button ids but for some reasons it's not working, it give me the error "undefined".
function Myfunc (){
var button1 = document.getElementById("_10erop07");
button1.click();
}
How Can i make a script, that at a certain hour, I enter code here will automatically trigger at the certain hour.
Basically, I want the script to click on the dropdown and select the "Break" status.
Any ideas how can I do that?
This can easily be done using Bookmarklets
follow the steps in the guide link above.
your javascript code should look something like this
javascript:(
function(){
// YOUR CODE SHOULD BE HERE
}
)();
But make sure to click the bookmarklet when you are in the website
I hope that helps.

Customize Javascript Alert NOT onclick

I have absolutely no idea about Javascript and don't know if it is even possible. Anyway, I found a script that customizes Javascript Alert Box. It works nicely. The issue I am having is that this customization works based on 'onClick' as below:
// Standard Dialogs
$("#alert").on( 'click', function () {
reset();
alertify.alert("This is an alert dialog");
return false;
});
However, my Alert Box is generated by different code, and it either generates Alert Box or redirects to another page, but has nothing to do with onClick function. My question is:
is it possible to customize the Alert Box which is generated outside of the onClick function? If so, could anyone let me know how?
And my sincere apologies if that subject was already explained somewhere - I was looking for an answer but could not find.
Thank you
If you're trying to have the alert pop up initially without prompt it appears you will need:
alertify.alert("This is an alert dialog");
to be pasted outside of the function.
This will trigger the alert when the page loads as long as your tags are at the bottom of your html &/or you've used a document.ready statement.
My other interpretation of your above message is that the code above works and another alert box doesn't in which case can you please show us the code from the code that is not displaying as customised.

Make browser's back button work when using hide and show (jquery)

I've seen the new website of megaupload (mega) and we've got this:
Ok, if I press on left-menu contacts, it only reloads the white part on the image, if I press messages, the same, it only reloads white part. But if I go from contacts to messages and I press browser's back button, it goes from messages to contact and only reloads white part as always.
In my website, I do the same using jquery hide and show, but obviously, if I press browser's back button it doesn't hide the div and shows the other one.
My web site is only one html file and there are 4 div that get shown or hidden depending on the button you press, this is an example:
$("#btn_contact").click(function () {
$("#content_contact").show();
$("#content_home").hide();
$("#content_products").hide();
$("#body_aux").hide() ;
$(this).addClass('visited');
$('#btn_products').removeClass('visited');
$('#btn_home').removeClass('visited');
});
Can anybody tell me how to find this with jquery or whatever I have to use.
I don't know if I've explained myself well, if not, ask me to do it better.
I would appreciate any help. Thanxs a lot.
Maybe it'd be easier for you and more appropiate to make "content_contact.html", "content_home.html", and so on and use .load() function as Ozan Deniz said. You wouldn't have to change margins, positions, etc. and back button would work withouth programming. I think is not appropiate to make the whole website using just one html file, showing and hiding div's, ofcourse you can do this but maybe is not the right way. I'm newbie at this, but that's what an expert told me beacuse I was doing something similar to that.
Hope to help you.
You can use jquery load function to load white part
For example;
$('#result').load('ajax/test.html');
And in back button event you can load the white part
jquery hide and show
window.onbeforeunload = function() { $('#result').hide(); }; or
window.onbeforeunload = function() { $('#result').show(); };
jquery load function
window.onbeforeunload = function() { $('#result').load('ajax/test.html'); };

tinymce dont show the alert leaving the page

I am using jquery with normal version 3.4.3.2 (non-jquery).
I am using jquery to get contents of the box like this
$(function(){
$(".submit").click(function() {
var text = tinyMCE.get('elm1').getContent();
$(".here").html(text);
return false;
});
});
But when i edit the content of the textarea and click submit and then leave the page.
But it shows the alert box.
I dont want it to come if the users have clicked the .submit after editing.
Thanks
Brett seems right.
You can even use this to get the content into the form in case $(."here") ist the element you initialized the tinymce editor for:
$(".submit").click(function() {
tinymce.get('elm1').save();
return false;
});
Sorry to post in an old topic but I tried .save() and it did not work for me either. So, I figured out a better solution that I wanted to share for the next person.
The unsaved alert is part of the autosave plugin which checks function tinymce.get('mce1').isDirty(). This function checks the value of tinymce.get('mce1').isNotDirty
A "dirty" mce is one which has unsaved changes. So, to prevent the popup you have to tell mce that it is clean without any unsaved changes.
tinymce.get('mce1').isNotDirty = 1;//clean mce
That will prevent the popup when leaving/refreshing page, assuming no more edits are done to the content of mce1
If you have one editor per page try
tinymce.activeEditor.save();
See the documentation for more details
https://www.tiny.cloud/docs/api/tinymce/tinymce.editor/

Add jQuery colorbox plugin to a dynamically created element, extra problem

I saw the answer of a question: Add jQuery colorbox plugin to a dynamically created element
Solve part of the problem, works fine, but when I click for second time, it doesn't work.
When I try to click for second time an error displays: $.fn.colorbox is not a function.
How can i correct that error and avoid a double click to bind colorbox.
I don't speak english, i did my best to write this words, i hope you can read me. Thanks.
$('.colorbox').die().live('click', function() {
$.colorbox({href:$(this).attr('href'), open:true});
return false;
}
That should help you put a ".die()" before the ".live("

Categories

Resources