Calling a function on one page from a link on another page

I have an html page (django) that contains several divs (each of which displays different data) and one div that has navigation links. I will call it my main page. I have an external .js file (jQuery) that displays one div on the main page and at the same time hides all the others (except the navigation div) based on the selected navigation link.

$ (function () {

$("#sl_sectorbr").click(function showSectorMini(){
  $(".minimenu").hide();
  $(".minimenu > *").hide();
  $("#sector_mini").fadeIn("slow");
  $("#sector_mini > *").fadeIn("slow");
});

All of this works great. My question is: if I want to place "navigation links" on the second page of html; that when clicked, my main page will load And call / execute a certain function, for example "showSectorMini ()" just as if it was clicked on the main page itself - how would I write this code? I would really appreciate any help I could get.


Oh .... existing class ...

}
/* ------- Interaction Containers Class -------- */
.interactContainers {
padding:8px;
border:#999 1px solid;
display:none;
}

But you probably already knew that!

Steve


Gentlemen ...

This is exactly what I need, and mine is less complicated than that. Only one div to open with a script. So far I am incompetent javascript .: (

How do you carry it for my needs?

Separate link to the page:   <a href="myprofile.php?id='. $id .'" target="_parent">Email</a></div>

The page that goes to the code:

function toggleSlideBox(x) {
    if ($('#'+x).is(":hidden")) {
            $(".interactContainers").slideUp(200);
            $('#'+x).slideDown(300);

    } else {
        $('#'+x).slideUp(300);
    }
}

and div is ...

<div class="interactContainers"  id="interactContainers" style="background-color: #EAF4FF;">

( ) ... (id)... javascript toggleSlideBox.

javascript, IQ 4 .:\

, .

S

+3
3

- http://example.com/#sectionOne .

+2

SidneySM, - . :

js :

var initSectorUI = function(){
  if (location.hash) showSectorMini(location.hash);
};

var showSectorMini = function(sector){
  $('#sectors > div').hide();
  $(sector).show();
};

:

$(function(){
  initSectorUI();

  $("#navigator a").click(function(){ 
    showSectorMini($(this).attr('href'));
  });
});

<div id="navigator">
  <a href="#one">One</a>
  <a href="#two">Two</a>
</div>
<div id="sectors">
  <div id="one" style="display:none">A one</div>
  <div id="two" style="display:none">A two</div>
</div>
+2

You should organize different versions of the page and put different loading actions in each version. For example, make a div to show the request parameter, and make django to load correctly depending on the request parameter. Then put the various query parameters in the links.

0
source

Source: https://habr.com/ru/post/1711029/


All Articles