JavaScript

121K

Solutions

41K

Contributors

JavaScript is a dynamic, object-based language commonly used for client-side scripting in web browsers. Recently, server side JavaScript frameworks have also emerged. JavaScript runs on nearly every operating system and  in almost every mainstream web browser.

Share tech news, updates, or what's on your mind.

Sign up to Post

Disable client-side caching in all browser. We are using Angualrjs.
For disabling the cache, I used HTML meta tags:-
    <meta http-equiv="cache-control" content="no-cache" />
    <meta http-equiv="EXPIRES" content="0">
    <meta http-equiv="PRAGMA" content="NO-CACHE">
but need a best solution
i.e.: http://www.i18nguy.com/markup/metatags.html
0
The Ultimate Tool Kit for Technolgy Solution Provi
The Ultimate Tool Kit for Technolgy Solution Provi

Broken down into practical pointers and step-by-step instructions, the IT Service Excellence Tool Kit delivers expert advice for technology solution providers. Get your free copy for valuable how-to assets including sample agreements, checklists, flowcharts, and more!

Can any help with an example how to add a right click JS function to a Here Maps JS control.


I need to call a function on right click that populates the items of a context menu and then displays the context menu. I cant find any examples how to get a context menu working in the here maps api


https://developer.here.com/documentation/maps/topics_api/h-intro.html
0
Hi,

I am populating a highchart data via JS, the data is coming from a textbox on the page, this content is dynamically replaced:

        <script>
            function myFunction() {
                var myvar = document.getElementById("TextBox1").value;

                Highcharts.chart('piechart2', {
                    chart: {
                        plotBackgroundColor: null,
                        plotBorderWidth: null,
                        plotShadow: false,
                        type: 'pie'
                    },
                    credits: {
                        enabled: false
                    },
                    title: {
                        text: 'Data, 2018'
                    },
                    tooltip: {
                        pointFormat: '{series.name}: <b>{point.percentage:.1f}%</b>'
                    },
                    plotOptions: {
                        pie: {
                            allowPointSelect: true,
                            cursor: 'pointer',
                            dataLabels: {
                                enabled: true,
                                format: '<b>{point.name}</b>: {point.percentage:.1f} %',
                                style: {
                                    color: (Highcharts.theme && Highcharts.theme.contrastTextColor) || 'black'
                                }
                            }
                        }
                    },
                    

Open in new window

0
Hi Experts,

In NetBeans, is there a way to use Multi-Language characters in your code? I guess, unicode?

Example:
var office_ta = 'அலுவலகம்';

Open in new window


When I paste the Tamil, i just get squares.

Thanks.
0
I've been tinkering with React JS for the past several months now, and just have some questions.  I'm not looking for code .. just information and maybe some links.  Please advise.

1) I'm a bit confused about how security is maintained in React based applications.  I understand that the JS and CSS files get minified and bundled during the build process.  But what about the API keys and login credentials that are buried in the JS files in the site root when deployed?  Can't anyone just view source and extract that info, ... however obfuscated it might be?  I've always wondered why the tutorial videos I've watched never get in to any of  that.  What is it that I'm missing or not understanding?  

2) Why would I ever need or want to use Redux in my React based application?  My understanding is that it would facilitate something like "multiple undo levels" .. or work similar to a web browser's "back" and "next" buttons.  Am I correct in assuming that it's mostly used for debugging / troubleshooting purposes? If not, then what's an example of real life use case scenario?

3) Regarding the new Context API .. is it being regarded as an all-out replacement for Redux?  Or are the two fundamentally different?  If so, how?

4) What other real-time databases are available besides Firebase that work with React, if any?  I'd be most interested in 3rd-party hosted solutions (like Firebase), as opposed to database engines that you'd have to install and configure on your own server.…
0
How do i prevent double click on checkbox ?

 propCheck.one('change', actProp);

Open in new window


i have a few of these to trigger functions but how do i prevent double click.  one works but it means i cant reuse that checkbox until i refresh .

any tips
0
I have some Javascript that takes the url passed to the page from a form and extracts the parameters and creates an iframe with the src based on these parameters.

The script works fine in Chrome, safari and Firefox but not Internet Explorer (v10 or v11).

I have read that IE doesn't work with searchParams but despite spending several hours searching, I can't find a working alternative or even a clue to help me investigate.

The code I have is

<script>
//var url_string = window.location.href; For this example lets use a hardcoded url
var url_string = "http://mydomain.tld?arrival=05%2F09%2F2018&numberOfNights=1&numberOfPersons=1&request_local=en";
var url = new URL(url_string);
var request_locale = url.searchParams.get("request_local");
var arrival = url.searchParams.get("arrival");
var numberOfPersons = url.searchParams.get("numberOfPersons");
var numberOfNights = url.searchParams.get("numberOfNights");

var iframe = document.createElement('iframe');
iframe.setAttribute('id', 'booking-engine');
iframe.setAttribute('frameborder', '0');
iframe.setAttribute('class', 'c-iframe c-iframe--booking');
iframe.setAttribute('style', "height: 1250px;");

if(!arrival) {
iframe.setAttribute("src", "https://uk1.roomlynx.net/rezrooms2/loadOBMApplication.action?siteId=SITEID&request_locale=en&chainAction=newAvailabilitySearch");
}
else {
iframe.setAttribute("src", 

Open in new window

0
Hi,

We have the following Javascript code that is used on our intranet to hide/show side menus.

This code has been working perfectly fine for the last year or so and was written by someone who no longer works for the company. However over the past couple of days the side menus have stopped working in Google Chrome on all computers.

We are getting the following error:


Error

function show(menuChoice)
	{
		var el = document.getElementById(menuChoice);
		if ( el.style.display != 'none' )
			{
				Animation(document.getElementById(menuChoice)).to('height', '0px').to('opacity', 0).hide().go();
			}
		else
			{
				Animation(document.getElementById(menuChoice)).to('height', 'auto').from('0px').to('width', 'auto').from('0px').to('opacity', 1).from(0).blind().show().go();
			}
	}

function hide(menuChoice)
	{
		var el = document.getElementById(menuChoice);
		if ( el.style.display != 'none' )
			{
				Animation(document.getElementById(menuChoice)).to('height', '0px').to('opacity', 0).hide().go();
			}
		else
			{
				
			}
	}

Open in new window


Thanks, Greg
0
Hi

I want to count the number of times  an ID exist in an array using Reactjs reduce function. I am using typescript.
Getting error + cannot be applied to number and Boolean,



let count = this.props.controls.reduce(function (n, val) {
            return n + (val.einId == 10);
        }, 0);

        return count;

Open in new window

0
I know there's a ton of questions around date/time storage and formatting, but I'm struggling to get the right approach. My app is a Node.js app with Express using mongoose with a MongoDB backend. I'm using moment.js to format my date/times.

The schema in question looks like:

const stateSchema = new mongoose.Schema({
  changed: {
    type: Date,
    default: new Date()
  }
});

Open in new window

Based on the docs, I was expecting the date to be stored in UTC by default, but instead I see this:
changed: 2018-08-15 17:26:14.499

Open in new window

I'm displaying the date/time with something like (pug):

p= `Changed: ${moment(state.changed).format('MMMM Do YYYY, h:mm:ss a')}`

Open in new window

On localhost, the app shows "August 15th 2018, 5:26:14 pm" but on the hosted Heroku app I get "August 15th 2018, 10:26:14 pm." I am expecting "August 15th 2018, 5:26:14 pm" because I'm opening the Heroku app in the same timezone, but it looks like it's giving me the server timezone.

What should I do to make sure the date/time shows up in the client's local timezone?
0
Cloud Class® Course: Amazon Web Services - Basic
LVL 12
Cloud Class® Course: Amazon Web Services - Basic

Are you thinking about creating an Amazon Web Services account for your business? Not sure where to start? In this course you’ll get an overview of the history of AWS and take a tour of their user interface.

I have a 2 node DAG Exchange 2013 CU19.
I am trying to delete any email older than 1/1/2016 for a specific user, but no matter what I do, I get nothing from searchquery filtering.
I Have confirmed Roll group Membership for Discovery Management and Mailbox Import Export.
I tried every format of double and single quotes for the date, and could not find anything.
I then tried to remove something from my mailbox, and get the same thing.
I sent me an email with subject test, and can not find it either.

I have tried:
search-mailbox -identity ttaylor -searchquery subject:test -estimatresulteonly
search-mailbox ttaylor -searcquery subject:test -estiamateresultonly
search-mailbox -identity ttaylor -searchquery "subject:test" -estimatresulteonly
search-mailbox ttaylor -searcquery "subject:test" -estiamateresultonly

I always get the same output
RunspaceId       : 304008d0-fa23-40d9-8867-d6ea567d5b9c
Identity         : Domain/ou/Tim Taylor
TargetMailbox    :
Success          : False
TargetFolder     :
ResultItemsCount : 0
ResultItemsSize  : 0 B (0 bytes)

Any suggestions
0
Hello Experts,

I’m trying to filter a drop down list based on another dropdown list using SQL/vbscript/hta. I have it working sort of thanks to Experts Exchange where I can populate the dropdowns from the database.

Now, I need to do two things:

1. Filter the dropdown lists
2. Send the values to a text file

The query in the code below shows the data like this:

ARA_PERSON_ID               ARA_TYPE_DESC                     INVOICE_TERM_DESC
0000000                                Student - Credit                       2004 Fall Reporting Term
0000000                                Student - Credit                       2004 Spring Reporting Term
0000000                                Student - Credit                       2005 Intersession Reporting
0000000                                Student - Credit                       2009 Fall Reporting
0000000                                Student - Credit                       2012 Fall Reporting
0000000                                Student - Credit                       2013 Fall Reporting
0000000                                Student - Credit                       2013 Spring Reporting
0000000                                Student - Credit                       2016 Spring Reporting
0000000                                Student - Credit Free               2003 Fall Reporting Term
0000000                                Student - Credit Free               2004 Spring Reporting Term
0000000                                Student - Credit Free               2006 Fall Reporting Term


 But I need it to show like this:
0
I am needing to deliver some js files to a desktop application that runs in a browser shell.  The reason I am doing it this way is I don't have a web server.  This has been running successfully for months until recently the cdn references to libraries like jquery no longer consistently download each time the app opens.  The app is running on windows 7 and uses IE 11 for the shell.  In replacement of a web server I thought about using SSRS since we have a db server.  I can't get the dba to turn on iis on that server as well but thought about placing the files on ssrs and then pointing the script tag src to http://ssrs-server/ReportServer?/Apps/Libraries/jquery.min.js.  When I test this I see the reference to the file in the temporary internet files folder so it appears to download but the initialization in code of jquery fails as if it were not available.  So maybe I don't fully understand what is being listed in the temporary internet files folder and how the app uses the js file from this location.  Does anyone have any suggestions as to what may be wrong or it there some type of conflict with ssrs in the opening of the file.  I can click directly on the file listed in ssrs in the folder view and it opens like a hyperlink showing the js file content.  Thanks for your input.
0
For our radio station I want to display on our website, on specific days and hours, images of the current DJ program.

For example: Monday  12:00 AM to 8:00 AM display stationlogo.png
             Monday  8:00 AM to 10:00 AM display DJjoe.png
             Monday  10:00 AM to 12:00 PM  display DJstan.png
             Monday  12:00 PM to 4:00 PM display stationlogo.png
             Monday  7:00 PM to 9:00 PM display DJmike.png
             Monday  9:00 PM to 12:00 AM display statonlogo.png

This will be for all seven days of the week with different schedules on different days. I have seen and tried many php and java scripts from the internet to accomplish this, but so far none of them actually work, or are limited in some way. I assume this has to be on my server so that the times will be consistent across time zones. We are all Vietnam veteran volunteers and not tech experts, so any help is greatly appreciated.

Thank you
0
Javascript Modular Pattern

Trying to understand the Javascript Modular Pattern
I looked at this example from here:
https://stackoverflow.com/questions/17776940/javascript-module-pattern-with-example


I do not understand when he called twice the add method, why it incremented the value of sum, I thought it will get reset to 0:

alert(modularpattern.add());    // alerts: 1
alert(modularpattern.add());    // alerts: 2
alert(modularpattern.reset());  // alerts: 0
Thank you.
var scope = "I am global";
function whatismyscope() {
    var scope = "I am just a local";
    function func() {return scope;}
    return func;
}
whatismyscope()()
Now we will apply these three concepts I mentioned above to define our first modular design pattern:

var modularpattern = (function() {
    // your module code goes here
    var sum = 0 ;

    return {
        add:function() {
            sum = sum + 1;
            return sum;
        },
        reset:function() {
            return sum = 0;    
        }  
    }   
}());
alert(modularpattern.add());    // alerts: 1
alert(modularpattern.add());    // alerts: 2
alert(modularpattern.reset());  // alerts: 0

Open in new window

0
I have a array of knockout objects

  function topicInfo(data) {
        this.id = ko.observable(data.id);
        this.active = ko.observable(data.Active);
        this.indication = ko.observable(data.indication);
        this.name = ko.observable(data.name);
        this.title = ko.observable(data.Title);
        this.trainedDate = ko.observable(moment(data.trainedDate).format("MM/DD/YYYY"));
    }

Open in new window


and they are populated with:

        if (data.topics) {
            var maptopics = $.map(data.topics, function (topic) {
                return new topicInfo(topic);
            });
        }


   this.topics= ko.observableArray(maptopics);

Open in new window


And need a distinct based on the name field


        this.activeTopicsDistinct = filterByFirstOccurance(this.activeTopics(), "name");    // make it easy for the HTML to display

Open in new window


Topics:
0
audio works in all desktop browsers but on mobile IOS Safari it doesn't work.  

http://www.kyoukhana.com/audio/

When I click on play the audio doesn't play on Safari which i running 11.4.1
0
I would like to create a "sticky" header nav bar that will always be on the top of the page, when you scroll.

But I want the nav bar to animate by shrinking a little bit. Here is a perfect example of exacty what I am tring to do:

https://cmitsolutions.com/scottsdale-south/

I would like to have it work just like that, where the phone number and such reamains until you scroll, and then disappears and the menu logo actually shrinks a little.

Can anyone help me out with a tutorial or short example? I love this effect, and really want to learn it for my next project.

Thank you!
0
I had this question after viewing Change a specific key value in app.config file with another value..

i have  a config file as below
<meeServices>
  <edmServers>
    <server name="EDMServer" description="EDMServer" username="" password="" integratedSecurity="true" />
  </edmServers>
  <rdmServers>
    <server name="EDMServer" description="EDMServer" username="" password="" integratedSecurity="true" />
  </rdmServers>
  <settings>
    <add name="ExposureSource" value="path" />
    <add name="DomainDatabase" value="Server=HeadNode;Initial Catalog=RMS_MEE_Data;Integrated Security=True;" />
    <add name="ResultsDatabase" value="Server=HeadNode;Initial Catalog=RMS_MEE_Results;Integrated Security=True;" />
    <add name="JobManagerService" value="url" />
    <add name="licensecode" value="code" />
    <add name="WhiteListedIPAddresses" value="*" />
  </settings>
</meeServices>

 in settings , i want to change the name which contains licensecode to newcode. how do i do this.

$ConfigFile = 'C:\Users\psman\Downloads\dev_qa.config'
## XML Node names and Attributes are CaSe SeNsItIvE!
$xml = [xml](Get-Content -Path $ConfigFile)

$xml.SelectSingleNode("meeservices/settings/add[@name='licensecode']").SetAttribute("name", "data1")

$xml.Save($ConfigFile)
0
Creating Active Directory Users from a Text File
LVL 8
Creating Active Directory Users from a Text File

If your organization has a need to mass-create AD user accounts, watch this video to see how its done without the need for scripting or other unnecessary complexities.

Hi,

I am trying to pass a div id from XSL to Java script to open the value of div in a modal pop up.
I used the following code - http://jsfiddle.net/uKaBH/
Only difference between the code in this jsfiddle and mine is, I need to do it for multiple div values. PFB a sample of my code.

<html lang="en">
   <head>
      <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
      <meta charset="utf-8">
      <title>jQuery UI Dialog - Default functionality</title>
      <link rel="stylesheet" href="http://code.jquery.com/ui/1.10.3/themes/smoothness/jquery-ui.css"><script src="http://code.jquery.com/jquery-1.9.1.js"></script><script src="http://code.jquery.com/ui/1.10.3/jquery-ui.js"></script><link rel="stylesheet" href="/resources/demos/style.css"><script>
          $(function() {
            $( "#{$AID}" ).dialog({autoopen: false});
            $( "#{$AID}" ).dialog("close");
          });
          $(document).ready(function() {
            $('#{$CID}').click(function() {
              $( "#{$AID}" ).dialog({ modal: true });
            });
          });
        </script></head>
   <body>
      <div class="section">
					<div colspan="4" class="sectionHeader">
						<b>Attachments</b>
					</div>
					<xsl:for-each select="/file/notes/note">
					   <table width="100%" class="clsGridTableBase">
							<tr>
                                <xsl:variable name="CID" value="generate-id()"/>						
								<td id="{$CID}" title = "Click to View Content">
				

Open in new window

0
I need help with a DataTable.  I need to filter out rows that meet a certain criteria.  I am using grouped tables like this:

$('table.groupedtable').DataTable({
            "aaSorting": [],
            "pageLength": 1000,
            "columnDefs": [
                { "visible": false, "targets": 1 }
            ],
            "drawCallback": function (settings) {
                var api = this.api();
                var rows = api.rows({ page: 'current' }).nodes();
                var last = null;
                api.column(1, { page: 'current' }).data().each(function (group, i) {
                    if (last !== group) {
                        $(rows).eq(i).before(
                            '<tr class="group"><td colspan="9">' + group + '</td></tr>'
                        );
                        last = group;
                    }
                })
            }
        });

Open in new window


I have searched and found this code:

var filteredData = table
                    .rows()
                    .indexes()
                    .filter(function (value, index) {
                        return table.row(value).data()[9] == "Complete";
                    });
                table.rows(filteredData)
                    .remove()
                    .draw();

Open in new window

I'm not sure where to place this within the grouped table function.  I tried adding it after the draw Callback Function and I get table not defined errors.

Thanks for any help!
0
Hello Experts,
I hope somone can help.... I am using MapBox for one of my projects with 3 layers for each POI type. Each POI layer using a custom icon SVG I uploaded via the MapBox Studio.
I am showing a popup when the user click on each POI and the popup is position fixed on the Map.
Currently the size of the icon SVG is set at 0.75. I need somehow to increase the size of the icon or replace the icon (what ever is easier) when the user click or mouseover each POI.
Below is my current script:


mapboxgl.accessToken = 'xyz'; 
 
	 var geojson = {
		type: 'FeatureCollection',
		features: [{
			type: 'Feature',
				geometry: {
					type: 'Point',
					coordinates: [19.225290,56.551136]
				},
		}]
	 };

		var map = new mapboxgl.Map({
			container: 'map',
			style: 'mapbox://styles/xyz/cjk4c9eaj2tv22rqp316keuaq',
			center: [19.225290,56.545136], // starting position [lng, lat]
			zoom: 13.5,
			scrollZoom: false,
			pitch: 10,
			rotation:10,
		});


var lastZoom = map.getZoom();

map.on('zoom', function() {
  const currentZoom = map.getZoom();
  if (currentZoom < 13 || currentZoom > 14) {
    $(".marker").hide();
  } else {
     $(".marker").show();
  }

  lastZoom = currentZoom;
});


map.on('load', function() {
	
	var layers = ['slf-urban', 'slf-land', 'slf-park'];

	var layer = $('#map-filters input[type="checkbox"]').on("change", function(c) {
		
		var thislayer = $(this).attr("id");
		
		if(thislayer == "slf-all") {
			for (var i = 0; i < layers.length; i++) {

Open in new window

0
Morning all, I'm looking for some code that will enable IE and Chrome to go fullscreen when the web page opens. We have a number of browsers, so a single bit of code would be great.

I've added the current code I have.

What would be the best method to achieve this?

Many thanks

<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Edward</title>
</head>
<body bgcolor="#000000">
<!--url's used in the movie-->
<!--text used in the movie-->
<!--
:
Min
Sec
-->
<!-- saved from url=(0013)about:internet -->
<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=8,0,0,0" width="1280" height="1024" id="Edward" align="middle">
<param name="allowScriptAccess" value="sameDomain" />
<param name="movie" value="Edward.swf" /><param name="quality" value="high" /><param name="bgcolor" value="#000000" /><embed src="Edward.swf" quality="high" bgcolor="#000000" width="1280" height="1024" name="Edward" align="middle" allowScriptAccess="sameDomain" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" />
</object>
</body>
</html>

Open in new window

0
Hi I have this page where a background image blurs on Scroll (transition to a different image) + Simple Parallax. It works great in Chrome, but not working as expected in IE11. It's not broken, per se, just not working as intended.
0
I am trying to export the div content to PDF using jsPDF

function demoFromHTML() {
    var pdf = new jsPDF('p', 'pt', 'letter');
    // source can be HTML-formatted string, or a reference
    // to an actual DOM element from which the text will be scraped.
    source = $('#customers')[0];

    // we support special element handlers. Register them with jQuery-style 
    // ID selector for either ID or node name. ("#iAmID", "div", "span" etc.)
    // There is no support for any other type of selectors 
    // (class, of compound) at this time.
    specialElementHandlers = {
        // element with id of "bypass" - jQuery style selector
        '#bypassme': function (element, renderer) {
            // true = "handled elsewhere, bypass text extraction"
            return true
        }
    };
    margins = {
        top: 80,
        bottom: 60,
        left: 40,
        width: 522
    };
    // all coords and widths are in jsPDF instance's declared units
    // 'inches' in this case
    pdf.fromHTML(
    source, // HTML string or DOM elem ref.
    margins.left, // x coord
    margins.top, { // y coord
        'width': margins.width, // max width of content on PDF
        'elementHandlers': specialElementHandlers
    },

    function (dispose) {
        // dispose: object with X, Y of the last line add to the PDF 
        //          this allow the insertion of new lines after html
        pdf.save('Test.pdf');
    }, margins);
}
<script 

Open in new window

0

JavaScript

121K

Solutions

41K

Contributors

JavaScript is a dynamic, object-based language commonly used for client-side scripting in web browsers. Recently, server side JavaScript frameworks have also emerged. JavaScript runs on nearly every operating system and  in almost every mainstream web browser.