Add variable to end of url or dynamically ajax reload tab - javascript

This is a little hard for me to explain as i am not much of a coder. So here we go.
I have script that is mostly encoded with ion cube. Not i have an addon that is also encoded. The addon is loading in a tab number 5. The problem is that every time i click on a function in the tab that complete page reloads, and you have to navigate back to tab 5 to see the results.
So this is what i am thinking. As i can't edit code and the make of the code doesn't know when they are adding tab support to their little piece of code. i figured that there are two options
1 Force the following variable to the end of the url #tab5 so that when people click a function they will not have to navigate back to the tab. How do i do this coding wise, javascript or something else and what would code be or where would i look to code something like that. I have looked everywhere but nothing really applies to my situation
2 I think it would also work if each function which is called just reloads that section of the page in an ajax field so that not the full page is being reloaded.
Who can help find the right solution.
thanks

Related

ChessboardJs: Javascript Boards Work Only The First Time

Edit: The page code can be found on my page URL. I don't know where the fault might be. Please help.
Problem:
When we click to the chess puzzles page for the first time, they work. However, the boards vanish when we re-click to them from the homepage.
Demo:
This is the home page.
You click on a player's picture and you are taken to this page. Please note that the boards appear in this one.
But you see that link to go back to the puzzle list. You click on that and you land on the home page again.
Now, if you click on any of the players' photo (or even the same player's photo), this is what you get.
From now on, none of the puzzle links would work.
You can check it yourself at chess-puzzle.com.
Few information:
The site used Cloudfare. I tested with Cloudfare (inactive) a few minutes back yet the problem is not resolved.
I validated JS and it seems to be okay.
I have only one CSS file on my own (mycss.css). Other external files came with the piece of software.
I don't know which code to share because I don't know why this might happen. Though I can share any code by editing this question if asked for.
Can anybody please provide an answer to this.
The problem is that you have the attribute async in the scripts (jquery, chessboard) and that means that they do not load in any particular order.
But, the chessboard uses jquery at some points so if the chessboard script loads/runs first it will crash because it does not find jquery.
The script at the bottom will also fail as it might run before jQuery is loaded.
Finally you have included the chessboard script twice in the `head.
The best solution for your case would be to move the scripts at the bottom of the body, right above your inline script and remove the async attribute from them.

javascript scratchblocks squarespace

I would like to use Scratchblocks (a tool for rendering visual Scratch code blocks from a text listing, on GitHub) on my Squarespace website. The problem I am getting is that the scratchblocks are never rendered on the first load - but only after a refresh.
This is in the header (set in the header for that particular blog):
<script src="https://scratchblocks.github.io/js/scratchblocks-v3.1-min.js""></script>
Then I think I need to call this function at the end of the page - I've put it in the footer:
scratchblocks.renderMatching('pre.blocks');
NOTE: When I view the source I sort of see this JavaScript twice at the end of the page. Not sure what is happening there.
Here's an example of it on my website, where it renders the scratchblocks only after a refresh. [UPDATE - following the fix provided below, this now renders first time, every time as far as I can tell.]
[http://www.glennbroadway.com/coding-zone/2017/4/6/simple-collisions-in-scratch]2
Here's an example of someone else using it and it working properly. I've inspected the source and I can't work out how they are doing it.
https://codeclubprojects.org/en-GB/scratch/memory/
I've also tried all the different methods listed elsewhere on stackoverflow for getting javascript to load only after the HTML has finished. I can't get any of them to work - but I think the problem is something to do with Squarespace, I just don't have the knowledge to work out what.
Any help would be greatly appreciated.
In Squarespace, when your custom Javascript only works after a page refresh, it most likely has to do with Squarespace's AJAX loading:
Occasionally, Ajax may conflict with embedded custom code or anchor
links. Ajax can also interfere with site analytics, logging hits on
the first page only.
You may be able to disable AJAX for your template. Or, see the other approaches outlined here: https://stackoverflow.com/a/42604055/5338581 including:
window.addEventListener("mercury:load", function(){
// do stuff
});
In addition, I would generally recommend placing custom code in the "Footer" code injection area unless you have a specific reason to do otherwise.

Javascript: Redirecting to another site through a popup

I'm quite bad with Javascript and I can't work out a solution I need help to. I'm having a website and I'm trying to make a redirection to another site, but through a popup.
Example :
<script>alert(This will prompt up the message)</scrip>
<script>window.location="http://This-will-redirect-me-to-another-link.com";</scrip>
Like you can see I could simply use the second javascript to redirect the persons to another page, but due some reasons I can't use it as it will work only for half of the page(the script would be kinda 'sandboxed'), but if I'd make a popup(the first alert script) the second script would get out of the 'sandbox'. Is there anyone who has any ideas how I should implement this or can it be done otherwise with PHP or HTML?
I'm having a MyBB forum and there's a shoutbox for it which I'm using. There's a command which will change the notice of the shoutbox and the command is as such /notice New notice | But I noted that the new notice can be changed with javascript and it'll work such as /notice js code here | Then I thought that what if I would make such a javascript that would redirect people to another webpage. As I'm having such a forum where it's needed to redirect from the main page to another one, I'd like to apply it. Then Staffs could do it in the forum very well, but there's a problem. by adding
/notice window.location="http://This-will-redirect-me-to-another-link.com";
It'll affect only the shoutbox and shoutbox is being redirected to another webpage, but as an alert works for the whole forum I thought maybe I can redirect them to somewhere else with the alert. I want to know is it possible with just one script then Staffs would be able to do it. I know it's a serious security risk & it can be otherwise also, but I'd really like to experiment with it.
I hope someone can help. :)
Try:
window.open('url to other site', 'window name', 'width=900,height=650,scrollbars=yes');
If I understand you (if not please correct me), you can put a tag on popup or another place:
<a href="http://another.site.com/"
onclick="return confirm('Do you want to see another page?');">Redirect</a>

VBA Internet Explorer Download

First of all, I want to say that stackoverflow has helped me a GREAT deal with my current project, so thanks! But I have hit a point where I can no longer find help by skimming through previous questions. First, a little overview of what I'm doing.
At my job we have this extremely tedious process that we perform regularly, and I really want to automate it. The process is very basic, we go to a website, log-in, navigate to the appropriate page, copy and paste 6 values from excel into a form on the website, submit the form and download a specific output report. We repeat the process 60 times so this seemed like a prime candidate for Excel-Internet Explorer automation.
I built a pretty basic Excel Macro that can open up a new window with the appropriate URL, log-in, navigate to the correct page, fill in the form and submit the form, but I cannot figure out how to download the report. There is some added complexity to this, and I am just not familiar enough with Javascript, PHP ect. to figure out what is going on.
Problem: when I choose the correct report to generate, a new window pops-up with the generated report. This page is essentially empty when I click "View Source Document." There is a link to a Javascript page in the header, there is a little bit of CSS directly in the page, and like two tiny snippets of HTML. There is a download button on this page, but it doesn't look like it's being created in HTML.
QUESTION 1: Is this a Javascript application? Is there a way for me to simulate pressing the download button?
From what I understand, the complexity of my macro will increase substantially if I have to navigate between two IE windows, (not to mention there isn't an HTML link for me to click to download the spreadsheet) so I started to try and figure out a different way to do this. I looked at the URL of the new window with the generated report, and tried to analyze what was happening with Firefox's Developer tools (specifically Web Console). Here's where I get even more lost...
There are a series of "POSTS". These POSTS show up when the output is being created within the website:
POST https://www.website.com/somethingdb/quickframe/prod/#####/single_frame_results/correct_output.asp?THIS_KEY=370120c59da884dbdc375b1582a2142c1363533393a313335363032353737363a3646314a313937334a32353030303&bEmbedded=1
POST https://www.website.com/somethingdb/javascriptsource/prod/#####/website/forms/datagrid/DataGrid.html
POST https://www.website.com/qc?function=QuickFrameRmi
Then when I click the Download button, One POST and one GET show up:
POST https://www.website.com/qc?function=CorrectReport.generateExportFile
GET
GET https://www.website.com/somethingdb/quickframe/prod/#####/dlf/x6::370120c59da884dbdc375b1582a2142c1363533393a313335363032353737363a3646314a313937334a323530303031356026339.xls/sfn/RIGHTPAGE_scen_1_deal_cf.xls
The referrer for the GET looks like this:
https://www.website.com/somethingdb/quickframe/prod/#####/single_frame_results/correct_output.asp?THIS_KEY=370120c59da884dbdc375b1582a2142c1363533393a313335363032353737363a3646314a313937334a32353030303&sPagename=RIGHTPAGE&nScenarios=1&bShowExtendedFields=1&bShowAllCollats=0&ShowUnderlyingPage=0&sUnderlyingPage=&WebsitewrapDb=websitewrap&iSettleId=&bScrollbars=true&time=1356025839577
Like I said, my knowledge of these things is very limited but I do know that once I click on the download button, the GET from above is an actual file name that is stored on the website’s server. I can go into Excel, click on “Open” and put that file path in and it will download EXACTLY what I need.
So here is what I am thinking. If I could tell the website to simulate the download process, and log what that GET is, then I could just store that away, and when the Macro finishes generating all of the reports I need, it can just navigate back into Excel and set up a simple Loop to download all of them?? I have identified the portions of the GET that change:
x6::370120c59da884dbdc375b1582a2142c
63032353737363a3646314
6026339
This is my first post, so I apologize if I was too long winded in my back-story. Just wanted to be as clear as possible from the get go. I am wondering what is truly happening inside the website? Is what I am suggesting making sense? Is it possible? Is there a better way. Thanks in advance for any help.

Firebug can't choose script

I messed something up. In firebug I select the scipts tab, then click on inline and select the script I would like to step through with some break points. I am reasonably sure I have done this with the script before.
Now after removing and reinstalling firebug, clearing cache etc., scratching my head, when I select any of the scripts, the script briefly shows up and then immediately drops back to the HTML page that includes the script. If I'm quick, when I select the script I can scroll down and when I stop, it scrolls up, on it's own, line by line and when it reaches the top it goes back to the HTML page that has included the script
So from the screenshot, there are some js scripts below (cropped them out, didn't want to share the names). I've tried checking and un-checking inline with now result. I have a feeling it's related to my swiss cheese knowledge of js and web programming.
I hate to answer my own question, but I don't want to leave this post incomplete, so feel to improve on the answer. I don't plan to give myself the check unless there appears to be no further activity. I found a bug fix at issue #5134, and installed the 1.10.0a6 update found here and one last thing, the auto-scrolling stopped when I toggled the "Break on next" button pictured below. (the yellow pause button below the firebug.
Im not sure how can further can I assist without having to see the live site or some codes that may point to some explanation. However, here are some tricks that might help.
I use FirefoxAurora that comes with a tab called Changes. or maybe I install the Firebug extension somewhere. I forgot. But googling it up, this may be it Firediff.
The tab looks like the image attached and it will Diff the changes inside a page and then you might have a clue what's going on. It's detect element/attributes changes (not sure about inline script).
P/s: Somehow it doesn't work now, forgot how I've tested before. The url above have more explanation on this. But do check it out. Its been useful to me last time.

Categories